如何解决导致Flutter应用启动失败的异常?

时间:2019-12-30 19:12:01

标签: android-studio gradle flutter dart

我正在尝试实现google admob,以将广告添加到我的应用程序中,但是当我这样做时,我开始遇到异常。这是我当前遇到的构建错误

BUILD FAILED in 4s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin firebase_admob...

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.0+10\android\build.gradle' line: 22

* What went wrong:
A problem occurred evaluating root project 'firebase_admob'.
> Failed to apply plugin [id 'com.android.library']
   > Minimum supported Gradle version is 5.1.1. Current version is 4.10.2. If using the gradle wrapper, try editing the distributionUrl in D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.0+10\android\gradle\wrapper\gradle-wrapper.properties to gradle-5.1.1-all.zip

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

它表示build.gradle文件的第22行,如下所示:

apply plugin: 'com.android.library'

任何建议都值得赞赏!谢谢!

1 个答案:

答案 0 :(得分:0)

您需要将Gradle版本升级到5.1.1

android/gradle/wrapper/gradle-wrapper.properties

更改

  

distributionUrl = https://services.gradle.org/distributions/gradle-4.10.2-all.zip

  

distributionUrl = https://services.gradle.org/distributions/gradle-5.1.1-all.zip

android/build.gradle中 在 buildscript->依赖项下,更改

  

classpath'com.android.tools.build:gradle:3.3.2'

  

classpath'com.android.tools.build:gradle:5.1.1'

然后重试。