【问题标题】:Multiple Dex files error. Landroid/arch/lifecycle/LiveData$1多个 Dex 文件错误。 Landroid/arch/生命周期/LiveData$1
【发布时间】:2018-03-03 17:18:05
【问题描述】:

请帮帮我。我已经被这个问题困扰了很长时间。构建应用程序时出现此错误

错误:任务 ':app:transformClassesWithDexForDebug' 执行失败。 com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: 多个dex文件定义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'

【问题讨论】:

  • 首先消除dependencies 中的所有+ 符号,而是提供您要使用的依赖项的特定版本。
  • 那没有解决。
  • 好的。 libs/ 中是否有任何 JAR?
  • 不,我在库中没有任何 JAR。它是空的。
  • 好的,简单的解决方案就这么多。 :-( 在 Android Studio 中,当您将项目树设置为 Project 视图时,树的底部将是一个名为“External Libraries”的折叠分支。如果您打开它,它将向您显示所有依赖项您正在拉入,包括传递依赖项。如果您打开这些依赖项,您将在每个中看到 classes.jar,如果您进入这些,您将看到来自该依赖项的 Java 类。

标签: android build.gradle dex build-error


【解决方案1】:

只需将 firebase ui 版本修复为 3.2.2。 改变

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

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

【讨论】:

  • Firebase 建议将 firebase-ui 版本 2.2.0 与 firebaseauth 或 playservices 版本 11.0.4(我使用)一起使用
  • 我用的是 3.2.2,好像没问题。但这个建议的原因很有趣。您能否提供此建议的链接?
  • 拯救了我的一天 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多