[英]How to fix AndroidX compatibility for Flutter in Android Studio?
I'm getting this error when trying flutter build apk
:尝试
flutter build apk
时出现此错误:
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleRelease failed with exit code 1
But I can make my code run directly on a phone or an emulator... I already created APK files with that project (and sent it to the stores).但是我可以让我的代码直接在手机或模拟器上运行……我已经用那个项目创建了 APK 文件(并将它发送到商店)。 The last APK was created on 2019/07/17.
最后一个 APK 是在 2019 年 7 月 17 日创建的。 Since then, I only added some data in lists.
从那以后,我只在列表中添加了一些数据。
I already tried to compile in the same conditions than the last time then :我已经尝试在与上次相同的条件下进行编译:
flutter clean
, etc.; flutter clean
等; Here are my dependencies :这是我的依赖项:
dependencies:
flutter:
sdk: flutter
cloud_firestore: any
firebase_auth: any
google_sign_in: ^3.2.4
flutter_datetime_picker: 1.0.7
numberpicker: any
flutter_svg: any
dio: any
path_provider: any
firebase_messaging: any
charts_flutter: any
barcode_scan: 1.0.0
unity_ads_flutter: any
progress_indicators:
Gradle files :摇篮文件:
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-auth:18.1.0'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
[EDIT] I changed my computer. [编辑] 我换了电脑。 Might it be the issue reason ?
可能是问题原因吗?
[EDIT 2] SOLVED [编辑 2] 已解决
Steps:脚步:
dependencies:
flutter:
sdk: flutter
cloud_firestore: any
firebase_auth: any
google_sign_in: any
flutter_datetime_picker: 1.0.7
numberpicker: any
flutter_svg: any
dio: any
path_provider: any
firebase_messaging: any
charts_flutter: any
barcode_scan: 1.0.0
unity_ads_flutter: any
progress_indicators:
It looks like some files were corrupted or lost during transfers to my new computer在传输到我的新计算机期间,某些文件似乎已损坏或丢失
I had the same problem, after a week of searching and mixing some of the answers I found, this was the one that finally worked我遇到了同样的问题,经过一周的搜索和混合我找到的一些答案后,这个终于奏效了
Follow the guide in: https://pub.dev/packages/barcode_scan But do this modifications:按照指南: https : //pub.dev/packages/barcode_scan但是做这个修改:
Edit your project-level build.gradle file to look like this:编辑您的项目级 build.gradle 文件,如下所示:
buildscript {
ext.kotlin_version = '1.3.30'
...
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
...
Edit your app-level build.gradle file to look like this:编辑您的应用程序级 build.gradle 文件,如下所示:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
...
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
...
}
And if when you compile the app says something about a difference between androidx appcompat 1.0.0 and 1.0.2 Go to your plugin build.gradle file and change on dependencies如果你编译应用程序时提到了 androidx appcompat 1.0.0 和 1.0.2 之间的差异,请转到你的插件 build.gradle 文件并更改依赖项
dependencies {
implementation 'androidx.appcompat:appcompat:1.0.0'
...
}
Update your gradle.properties file with this:使用以下内容更新您的 gradle.properties 文件:
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.