错误:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex

时间:2018-03-08 15:46:08

标签: java android multidex

我正在使用firebase在android studio中创建壁纸应用程序。 编译时出错了

  

错误:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex   错误:com.android.builder.dexing.DexArchiveMergerException:无法合并dex   错误:com.android.dex.DexException:多个dex文件定义Landroid / arch / lifecycle / LiveData $ 1;

我添加了“multiDexEnabled true”和 “实施'com.android.support:multidex:1.0.3'”

我也清理并重建我的项目

没有任何反应

的build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.jimdo.saifstudios.wallpfeb"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support:multidex:1.0.3'

    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.firebaseui:firebase-ui-database:3.1.2'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:recyclerview-v7:27.1.0'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-database:11.8.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}

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

2 个答案:

答案 0 :(得分:0)

看一下firebase-ui的文档。

https://github.com/firebase/FirebaseUI-Android

对于您使用的版本,您必须使用com.google.firebase:firebase-database:11.6.2

答案 1 :(得分:0)

如果您要在应用中扩展应用。在我的情况下,我通过添加MultiDex.install(this)修复它; to attachBaseContext(Context context)方法。

你可以看看: https://developer.android.com/studio/build/multidex.html

相关问题