【发布时间】:2019-08-13 14:41:10
【问题描述】:
我在尝试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
但我可以让我的代码直接在手机或模拟器上运行... 我已经使用该项目创建了 APK 文件(并将其发送到商店)。最后一个 APK 创建于 2019/07/17。从那以后,我只在列表中添加了一些数据。
我已经尝试在与上次相同的条件下编译:
-
flutter clean等; - 使缓存失效;
- 降级 Flutter 版本;
- 降级 Kotlin 版本;
- 降级 Gradle 版本;
- 降级 Gradle-wrapper 的分发 URL。
这是我的依赖项:
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 文件:
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"
}
[编辑] 我换了电脑。可能是问题原因?
[编辑 2] 已解决
步骤:
- 升级包
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:
- 复制新项目中的所有文件
在向我的新计算机传输过程中,某些文件似乎已损坏或丢失
【问题讨论】:
-
“失败可能是因为..”。您应该通过使用
--info运行任务来找到实际的 Gradle 错误。 -
@F-1 :我按照指南并在 AndroidX 的网站上查找了我需要的最新版本的实现。
-
@creativecreatorormaybenot :没有显示任何问题。只有自动替换过时调用的警告
-
@BarracudApps 执行
flutter build时不显示Gradle 错误。您将不得不手动调试失败的 Gradle 任务。如果你不明白我的意思,应该有足够的信息。
标签: android android-studio flutter compilation androidx