繁体   English   中英

Android Studio 3.0的DexArchiveMergerException

[英]DexArchiveMergerException with Android Studio 3.0

编译错误与以下build.gradle详细信息:

顶级build.gradle

buildscript {
repositories {
    google()
    jcenter()
    mavenCentral()
 }
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
 }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://maven.google.com' }
    }
}

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

App-Level build.gradle

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 27
        defaultConfig {
            applicationId "com.abc"
            minSdkVersion 15
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true

            dataBinding {
                enabled true
            }

            dexOptions {
                javaMaxHeapSize "4g"
            }
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

        // Android
        implementation 'com.android.support:appcompat-v7:27.+'
        implementation 'com.android.support:support-v4:27.+'
        implementation 'com.android.support:support-annotations:27.+'

        // RxJava & RxAndroid
        implementation 'io.reactivex.rxjava2:rxandroid:2.+'
        implementation 'io.reactivex.rxjava2:rxjava:2.+'
        implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'


        //Glide for images
        implementation 'com.github.bumptech.glide:glide:4.+'
        annotationProcessor 'com.github.bumptech.glide:compiler:4.+'

        // Retrofit : Network
        implementation 'com.squareup.retrofit2:retrofit:2.+'
        implementation 'com.squareup.retrofit2:converter-jackson:2.+'
        implementation 'com.google.code.gson:gson:2.+'

        // Multidex
        implementation 'com.android.support:multidex:1.+'

    }

这是错误

错误:任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'的执行失败。 com.android.builder.dexing.DexArchiveMergerException:com.android.tools.r8.errors.CompilationError:程序类型已存在:android.support.v4.app.ActionBarDrawerToggle $ DelegateProvider

首先,试试这个

  • 清理你的项目
  • 然后重建

如果问题仍然存在

  • 使catch和从文件菜单重新启动无效。

最后,如果仍然存在问题,请尝试这样做

删除
\\建立
。理念
.gradle
应用程序\\编译

然后重建。 希望这有帮助;)。

当我们升级android studio或gradle版本解决方案时,会出现此错误 -

请确保您正在添加稳定版本的firebase库并播放服务库。

当我切换到工作室3.1.2并通过检查这些链接上的所有版本解决并确保您使用的库模块必须具有与app相同的版本时,我遇到了同样的问题。

https://firebase.google.com/support/release-notes/android#latest_sdk_versions

https://developers.google.com/android/guides/setup

通过添加以下内容解决了此问题:实施'com.google.firebase:firebase-analytics:15.0.0'

很奇怪,但是,根据firebase文档,firebase-analytics包含在firebase-core中。

您不应该使用以+结尾的库。 你应该指定你的版本它将是:

        // Android
        implementation 'com.android.support:appcompat-v7:27.0.0'
        implementation 'com.android.support:support-v4:27.0.0'
        implementation 'com.android.support:support-
         annotations:27.0.0'

        // RxJava & RxAndroid
        implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
        implementation 'io.reactivex.rxjava2:rxjava:2.0.1'
        implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'


        //Glide for images
        implementation 'com.github.bumptech.glide:glide:4.3.0'
        annotationProcessor 'com.github.bumptech.glide:compiler:4.3.0'

        // Retrofit : Network
        implementation 'com.squareup.retrofit2:retrofit:2.3.0'
        implementation 'com.squareup.retrofit2:converter-jackson:2.3.0'
        implementation 'com.google.code.gson:gson:2.8.1'

        // Multidex
        implementation 'com.android.support:multidex:1.0.1'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM