Android Flutter AndroidX incompatibilities报错处理

https://blog.csdn.net/jiangyangll/article/details/99675406

报错信息:The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app

原因:AndroidX 不兼容

解决方案:

AndroidStudio中提示网址  https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility

In 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
In android/build.gradle, replace:

dependencies {
classpath ‘com.android.tools.build:gradle:3.2.1‘
}
by

dependencies {
classpath ‘com.android.tools.build:gradle:3.3.0‘
}
In android/gradle.properties, append

android.enableJetifier=true
android.useAndroidX=true
In android/app/build.gradle:

Under android {, make sure compileSdkVersion and targetSdkVersion are at least 28.

Replace all deprecated libraries with the AndroidX equivalents. For instance, if you’re using the default .gradle files make the following changes:

In android/app/build.gradle

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
by

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Finally, under dependencies {, replace

androidTestImplementation ‘com.android.support.test:runner:1.0.2‘
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2‘
by

androidTestImplementation ‘androidx.test:runner:1.1.1‘
androidTestImplementation ‘androidx.test.espresso:espresso-core:3.1.1‘
Avoiding AndroidX
If you want or need to avoid migrating to AndroidX, you’ll need to pin your plugin dependencies in your pubspec.yaml to the last major version from before they were migrated.

These are the last available versions of all the flutter/plugins packages that are pre AndroidX:

android_alarm_manager: 0.2.3
android_intent: 0.2.1
battery: 0.3.0
camera: 0.2.9+1
cloud_firestore: 0.8.2+3
cloud_functions: 0.0.5
connectivity: 0.3.2
device_info: 0.3.0
firebase_admob: 0.7.0
firebase_analytics: 1.1.0
firebase_auth: 0.7.0
firebase_core: 0.2.5+1
firebase_database: 1.0.5
firebase_dynamic_links: 0.1.1
firebase_messaging: 2.1.0
firebase_ml_vision: 0.2.1
firebase_performance: 0.0.8+1
firebase_remote_config: 0.0.6+1
firebase_storage: 1.0.4
google_maps_flutter: 0.1.0
google_sign_in: 3.2.4
image_picker: 0.4.12+1
local_auth: 0.3.1
package_info: 0.3.2+1
path_provider: 0.4.1
quick_actions: 0.2.2
sensors: 0.3.5
share: 0.5.3
shared_preferences: 0.4.3
url_launcher: 4.1.0+1
video_player: 0.9.0
webview_flutter: 0.2.0
Note that this is not an exhaustive list of all Flutter plugins that use AndroidX, and the AndroidX dependency in your app might be coming from another plugin besides these.

修改后,仍然报错:根据提示查得 android / build.gradle 中 ext.kotlin_version不能低于 1.3.0

所以解决办法:

buildscript {
ext.kotlin_version = ‘1.3.0‘
将版本更改为1.3.0,再次运行程序运行成功
————————————————
版权声明:本文为CSDN博主「JYliangliang」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/jiangyangll/article/details/99675406

原文地址:https://www.cnblogs.com/sundaysme/p/12557206.html

时间: 2024-11-13 08:16:58

Android Flutter AndroidX incompatibilities报错处理的相关文章

android studio :com.android.support:appcompat-v7:21.+ 报错

android studio :com.android.support:appcompat-v7:21.+ 报错: 在project——>app——>build.gradle修改: apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "com.example.ri

Android 线程更新UI报错 : Can't create handler inside thread that has not called Looper.prepare()

MainActivity中有一个按钮,绑定了save方法 public void save(View view) { String title = titleText.getText().toString(); String timelength = lengthText.getText().toString(); ExecutorService exec = Executors.newCachedThreadPool(); exec.execute(new NewsService(getApp

android studio - 导入工程报错[Plugin with id 'com.android.application' not found]

出错现象: 大概意思是找不到:com.android.application 插件,以上现象对于初学者来说会经常碰到,下面分析下产生的原因. 原因分析 首先来看看导入后的工程结构: 对于此工程结构,是否有个疑问? 这是未正常同步完成的结构,Gradle Scripts下面似乎少了个 build.gradle ,上图红框部分描述清楚了是 Module: GraphicsDemo ,表示该 build.gradle 是Module的,而不是Project的.来看看一个正常的 Project+Modu

Mac OSX Android 开发环境 模拟器报错

直接下载ADT mac版 模拟器报错处理 1. 显示隐藏文件命令 显示:defaults write com.apple.finder AppleShowAllFiles -bool true隐藏:defaults write com.apple.finder AppleShowAllFiles -bool false 2. 修改 /.android/avd/你的模拟器名字/emulator-user.ini window.x = 0 原因没有深究,可能和双屏有关? Mac OSX Androi

android studio创建模拟器报错解决 emulator: ERROR: This AVD's configuration is missing a kernel file!!

android studio创建模拟器报错 emulator: ERROR: This AVD's configuration is missing a kernel file!! 的解决办法 原因有二:1 没有,解决办法通过sdk mangager 下载 2 找不到,解决办法看系统环境变量path(此种情况多数发生在android Studio和EclipseADT同时存在的情况下) 原因是在刚刚安装完毕的androidstudio的sdk目录下没有system-image目录,也许有但没有相

Android Studio集成SVN报错:can't use subversion command line client : svn

Android Studio集成SVN插件,check out出代码后,每次开启都会在右上角出现如下错误: Can't use Subversion command line client: svn Probably the path to Subversion executable is wrong. Fix it. Errors found while svn working copies detection. Fix it. 下面直接上解决方案吧: 1.安装客户端http://ncu.dl

Android Studo 使用 JNI报错:java.lang.UnsatisfiedLinkError: Couldn't load XXX from loader dalvik.system.PathClassLoader

今天在使用Android Studio的时候突然发现代码没错,so包也引入了,各个版本都引入了,但是就是一直报错: java.lang.UnsatisfiedLinkError: Couldn't load serphone from loader dalvik.system.PathClassLoader 11-30 11:13:18.766 29255-29255/com.personal.tai.ronglianim E/AndroidRuntime: at java.lang.Runti

cocos2d-x android 添加新场景报错: undefined reference to `vtable for XXX'

转载自 居家懒人 http://www.cnblogs.com/JD85/archive/2012/09/17/2688128.html 加入写了新场景SecondScene,结果在cpp文件里类名地方报错说undefined reference to `vtable for SecondScene', 很简单,貌似是每个新场景都要先注册一下,找到jni-->Classes目录下的Android.mk文件,在 LOCAL_SRC_FILES := AppDelegate.cpp HelloWor

Flutter -- Mac上运行Android创建的Flutter的若干报错解决

上篇博文里,我运行起来了我在git上下载的一个flutter项目,同事(android开发)这段时间也在研究Flutter,并且他自己写了一个Demo,我寻思着把他的项目拿过来,我看能运行起来否,结果一大堆问题. 下面我列出来了一部分,在我经过半个小时的百度,以及对比git上下载下来的项目里面的配置.终于解决了,成功的在我的6s和模拟器上跑起来了. 下面附上了 应用的四张截图,给安卓同事 点赞 1.Command PhaseScriptExecution failed with a nonzer