错误引入:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.versionedparcelable:versionedparcelable' has different version for the compile (1.0.0-rc01) and runtime (1.1.0) classpath. You should manually set the same version via DependencyResolution
* 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 3s
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 amap_all_fluttify...
Running Gradle task 'assembleAarRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Task 'assembleAarRelease' not found in root project 'amap_all_fluttify'.
* Try:
Run gradlew tasks to get a list of available tasks. 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 562ms
Finished with error: The plugin amap_all_fluttify could not be built due to the issue above.
第一个问题:
升级AndroidX
- 修改 android/gradle/wrapper/gradle-wrapper.properties change the line starting with distributionUrl like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
- 在 android/build.gradle, 修改:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
- 为
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
- 在 android/gradle.properties, 添加
android.enableJetifier=true
android.useAndroidX=true
- 在 android/app/build.gradle:
Under android {, make sure compileSdkVersion and targetSdkVersion are at least 28.
-
用AndroidX支持的库替换所有不推荐的库。例如,如果使用默认的.gradle文件,请进行以下更改:
-
在 android/app/build.gradle
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- 修改为
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- 最后, 在android/app/build.gradle dependencies中的 {, replace下
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
- 修改为
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
第二个问题
升级一下依赖
- flutter clean
- flutter packages upgrade