Flutter编译APK时提示The Gradle failure may have been because of AndroidX incompatibilities in ...

在编译APK的时候,很可能有如下提示:

The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.

1、Android studio编辑器,主菜单 - Refactor - Migrate to AndroidX,点Migrate按钮

2、修改/项目目录/android/gradle.properties,后面添加

android.useAndroidX=true
android.enableJetifier=true

3、修改/项目目录/android/app/src/build.gradle,将

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.0' 

如果还是报错,可能是其它原因,可以参考 《Flutter在编译APK时出现Could not GET 'https://dl.google.com/dl类似的错误怎么处理》

评论

暂无评论