【问题标题】:Unable to MergeDex in Android Studio after updating Firebase and Google play services更新 Firebase 和 Google Play 服务后,无法在 Android Studio 中合并 Dex
【发布时间】:2018-09-03 07:12:51
【问题描述】:

我收到的错误是这样的:

错误:任务执行失败
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: 无法合并 索引

我的 build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "app.monmos"
    minSdkVersion 21
    targetSdkVersion 27
    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'
    }
    }
    buildToolsVersion '27.0.3'
    productFlavors {
    }
    }
    android {
    defaultConfig {
    multiDexEnabled true
     }
      }
   dependencies {
   implementation fileTree(include: ['*.jar'], dir: 'libs')
  implementation 'com.github.jd-alexander:android-flat-button:v1.1'
//Libraries
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-messaging:12.0.0'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
 implementation 'com.cepheuen.elegant-number-button:lib:1.0.2'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-core:12.0.0'
implementation 'com.google.firebase:firebase-database:12.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.android.support:support-annotations:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.firebaseui:firebase-ui-database:3.1.1'
}
apply plugin: 'com.google.gms.google-services'

这是我的项目 build.gradle 项目:

    buildscript {

        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.1'
            classpath 'com.google.gms:google-services:3.1.0'


            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

allprojects {
repositories {
    google()
    jcenter()
    maven { url "https://jitpack.io" }
 }
 }

 task clean(type: Delete) {
delete rootProject.buildDir
}

我已将 firebase 版本从 10.2.0 更新为 12.0.0,并且应用程序显示错误提示我合并 dex。我认为 2 个库正在发生冲突。

【问题讨论】:

    标签: java android android-studio merge


    【解决方案1】:

    这是因为以下 Firebase-UI:

    implementation 'com.firebaseui:firebase-ui-database:3.1.1'
    

    有一个strict dependencies 的:

    • Firebase/Play 服务版本 11.6.2
    • 支持库版本27.0.1

    所以,你需要根据它更改依赖关系。

    如果您需要使用最近支持的 Firebase/Play 服务,您可以查看文档,地址为Firebase-UI for Android

    【讨论】:

      猜你喜欢
      • 2018-04-11
      • 2019-01-28
      • 1970-01-01
      • 2018-04-15
      • 1970-01-01
      • 2018-08-23
      • 1970-01-01
      • 1970-01-01
      • 2018-04-07
      相关资源
      最近更新 更多