【发布时间】:2019-09-30 02:30:18
【问题描述】:
每当我尝试运行我的应用程序时,它总是会失败并出现此错误
- 出了什么问题: 任务 ':app:transformClassesWithMultidexlistForDebug' 执行失败。 com.android.build.api.transform.TransformException:生成主 dex 列表时出错。
我已经尝试解决了几天,但没有一个解决方案有效。
我尝试降级 Firebase 依赖项的版本,更改了最低 sdk 版本以及 Internet 上提供的许多其他内容。可能这是 firebase 依赖的版本问题,但我无法掌握。
这是我的 pubspec.yaml 文件
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
url_launcher: ^4.0.2
dio: any
path_provider: any
carousel_pro: ^0.0.13
firebase_messaging: ^5.0.1
sqflite: any
#cloud_firestore: ^0.7.4
firebase_database: ^3.0.0
photo_view: ^0.2.2
webview_flutter: ^0.3.4
flutter_webview_plugin: ^0.3.5
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.7.0
这是 app/build.gradle 文件,其中要对解决方案进行一些更改,但没有奏效。我没有添加完整的文件,只是添加了一些必不可少的部分。
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.technothlon.techno_app"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-messaging:17.3.3'
}
apply plugin: 'com.google.gms.google-services'
我的 build.gradle 文件
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.2.0'
}
我已经尝试了这些解决方法:
还有一些来自 Stack 和 Github 的其他解决方案,但没有任何帮助。我个人认为问题在于 Firebase 依赖版本 及其与 AndroidX 的兼容性。
如果有人能帮我解决这个问题,那就太好了,因为我现在已经 5 天以上无法解决这个问题了 :( .
【问题讨论】:
-
通过将 minSdkVersion 更改为 19 或 21 来检查,我遇到了类似的问题,这对我有用。
标签: android firebase dart flutter androidx