其他分享
首页 > 其他分享> > 多个Dex文件错误. Landroid /弓/周期/ LiveData $1

多个Dex文件错误. Landroid /弓/周期/ LiveData $1

作者:互联网

请帮帮我.我一直坚持这个问题已经很久了.我在构建应用程序时遇到此错误

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 Landroid/arch/lifecycle/LiveData$1;

这是我的应用级build.gradle文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
    applicationId "com.exploro.socialmediaapp"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    externalNativeBuild {
        cmake {
            cppFlags "-std=c++11"
        }
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
externalNativeBuild {
    cmake {
        path "CMakeLists.txt"
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.0',          {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.+'
compile 'com.android.support:recyclerview-v7:27.+'
compile 'com.android.support:design:27.+'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile 'com.android.support:support-v4:27.+'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
compile 'com.google.firebase:firebase-storage:11.0.4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.firebaseui:firebase-ui-database:2.2.0'
compile 'id.zelory:compressor:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.github.chrisbanes:PhotoView:2.0.0'
testCompile 'junit:junit:4.12'
}

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

解决方法:

只需将firebase ui版本修复为3.2.2即可.
更改

compile 'com.firebaseui:firebase-ui-database:2.2.0'

compile 'com.firebaseui:firebase-ui-database:3.2.2'

标签:android,dex,build-gradle,build-error
来源: https://codeday.me/bug/20190701/1347556.html