Android 用 dex 转换类进行调试

标签 android gradle firebase-realtime-database android-gradle-plugin

我运行 Firebase 数据库时出现错误。我已应用插件:'com.google.gms.google-services',但出现错误。我第一次运行程序时没有得到错误,但现在我得到了一个错误

我的错误:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zza;

构建.gradle

apply plugin: 'com.android.application'

 android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
    applicationId "com.yavuzoktay.foodapp"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
 }

 dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

//Add Library


compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-database:9.0.0'
compile 'info.hoang8f:fbutton:1.0.5'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'com.android.support:design:26.+'
testCompile 'junit:junit:4.12'



   }
   apply plugin: 'com.google.gms.google-services'

你的建议对我很重要

非常感谢!

最佳答案

您正在使用相同库的不同版本:

compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-database:9.0.0'
compile 'com.firebaseui:firebase-ui-database:1.2.0'

尽你所能 read here firebaseui 和 firebase 库之间存在依赖关系:

FirebaseUI Version  Firebase/Play Services Version
2.3.0               11.0.4
2.2.0               11.0.4
2.1.1               11.0.2
2.0.1               11.0.1
.....               .....
1.2.0               10.2.0

使用相同的版本来避免这些问题。

关于Android 用 dex 转换类进行调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46176507/

相关文章:

java - 如何设置编辑文本框的布局边距?

安卓旋转动画

spring-boot - 在 gradle 5 中查找 BOM 贡献的所有依赖项

gradle - Gradle:如何以每行状态运行测试?

swift - 如何基于 Firebase 创建字典,但定义的值是子节点,定义的值是父节点 [Swift]

node.js - Nodejs Firebase 和 Angular4 身份验证

android - 安卓的屏幕和通过HDMI连接的屏幕是否可以显示不同的内容?

android - 如何使用 "adb shell pm trim-caches "命令

android - 从终端收到的Gradle buildConfigField值

ios - Firebase 安全规则 : All Read Single Property?