android studio 3 build无法合并dex

问题描述 投票:0回答:3

你好,突然我的android项目显示此错误

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

com.android.builder.dexing.DexArchiveMergerException:无法合并dex

在某些日子之前一切都运转正常,几天之后我再次打开它并告诉我这个我已经尝试了我在这里找到的所有可能的解决方案但没有任何工作可以帮助我吗?

这是我的build.gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.fire.stmtfadmin"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}



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






dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.google.firebase:firebase-storage:11.0.4'
    compile 'com.android.support:cardview-v7:+'
    implementation 'com.google.firebase:firebase-messaging:11.0.4'
    implementation 'com.google.firebase:firebase-database:11.0.4'
    implementation 'com.firebaseui:firebase-ui-database:2.3.0'
    implementation 'com.google.firebase:firebase-auth:11.0.4'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
    compile 'id.zelory:compressor:2.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:26.1.0'
    compile 'com.yqritc:recyclerview-multiple-viewtypes-adapter:1.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.StevenDXC:DxLoadingButton:2.0'
    compile 'com.github.dmytrodanylyk:android-morphing-button:98a4986e56' // commit hash
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.android.support:multidex:1.0.0'
    compile 'br.com.simplepass:loading-button-android:1.12.1'
    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'
    implementation 'com.google.android.gms:play-services-maps:11.0.4'
}




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

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
android firebase android-gradle
3个回答
0
投票

要使用11.4.0版本的Firebase,您需要将maven url添加到build.gradle文件中,如下所示:

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }
}

0
投票

这可能是因为您使用以下依赖项:

compile 'com.android.support:cardview-v7:+'

这意味着你想使用最新版本。最新版本27.1.0。

尝试使用:

implementation 'com.android.support:cardview-v7:26.1.0'

永远不要使用+作为您的依赖版本。因此,如果将来出现任何问题,您可以重现和调试相同的构建。


0
投票

谢谢大家的回复,但唯一对我有用的解决方案是将此行添加到build.gradle(Module:app):

    implementation 'android.arch.lifecycle:extensions:1.1.0'

我希望这会有助于其他人

© www.soinside.com 2019 - 2024. All rights reserved.