无法合并Dex错误:Android Studio 3.0 [英] Unable to merge Dex error: Android Studio 3.0

查看:305
本文介绍了无法合并Dex错误:Android Studio 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一次又一次地尝试解决这个问题,但其他问题中提出的解决方案都不适用于我。在将我的代码与我的队友代码合并后,由于此错误,我无法运行我的应用程序。我已经多次清理并重建了我的项目,但错误仍然存​​在:


错误:执行失败,执行任务':app :transformDexArchiveWithExternalLibsDexMergerForDebug。
java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex




  

我试过修复gradle警告,更新gradle compile库语句,并将此标志放入我的默认配置中: multiDexEnabled true

产生不同的唯一解决方法是上面的标志,它允许我实际运行应用程序,但会发生不同的运行时错误:


E / AndroidRuntime:FATAL EXCEPTION:main
过程:com。 example.aaronliang.flow_v1,PID:11780
了java.lang.RuntimeException:无法获得供应商> com.google.firebase.provider.FirebaseInitProvider:>抛出java.lang.ClassNotFoundException:找不到类>融为一体。 google.firebase.provider.FirebaseInitProvider的路径:DexPathList [[zip文件] /data/app/com.example.aaronliang.flow_v1->17 7.apk],nativeLibraryDirectories = [/ data / app-> lib / com.example.aaronliang.flow_v1-177,/ vendor / lib,/ system / lib]]

以下是我当前的gradle构建文件:

项目构建:

  //顶层构建文件,您可以在其中添加对所有子项目/模块通用的配置选项。 

buildscript {
repositories {
jcenter()
mavenCentral()
}
依赖关系{

classpath 'com.android.tools.build:gradle:3.0.0'
classpath'com.google.gms:google-services:3.1.0'

// classpath'com.android .tools.build:gradle:2.3.3'
// classpath'com.google.gms:google-services:3.1.0'

//注意:不要放置您的应用程序依赖关系在这里;它们属于单个模块build.gradle文件中的
//
}
}

allprojects {
存储库{
jcenter()
maven {urlhttps://jitpack.io}
maven {urlhttps://maven.google.com}
}
}

任务清理(类型:删除){
删除rootProject.buildDir
}

应用程序构建:

 应用程序插件:'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '26 .0.2'
defaultConfig {
multiDexEnabled真
的applicationID com.example.aaronliang.flow_v1
的minSdkVersion 15
targetSdkVersion 26
的versionCode 1个
的versionName 1.0
testInstrumentationRunner android.support.test.runner.AndroidJUnitRunner
}
buildTypes {
释放{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}

依赖项{
编译fileTree (包括:['* .jar'],dir:'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',{
exclude group :'com.android.support',module:'support-annotations'
})
编译'com.android.support:appcompat-v7:26.1.0'
compile'c​​om。 android.support.constraint:constraint-layout:1.0.2'
compile'c​​om.android.volley:volley:1.0.0'
compile'c​​om.github.bumptech.glide:glide:3.7。 0'
编译'com.google.firebase:firebase-firestore:11.6.0'
编译'com.google.firebase:firebase-auth:11.6.0'
compile'c​​om。 google.firebase:firebase-core:11.6.0'
compile'c​​om.google.android.gms:play-services:11.6.0'
compile'c​​om.github.woxthebox:draglistview:1.5。 0
// compile'c​​om.github.PhilJay:MPAndroidChart:v3.0.2'
compile'c​​om.jjoe64:graphview:4.2.1'
testCompile'junit:junit:4.12'
}
apply plugin:'com.google.gms.google-services'

configurations.all {
resolutionStrategy.eachDependency {DependencyResolveDetails details - >
def requested = details.requested
if(requested.group =='com.android.support'){
if(!requested.name.startsWith(multidex)){
details.useVersion '25.3.1'
}
}

}
}

任何帮助将不胜感激,因为这个项目即将到期!

解决方案

好吧,我设法解决了我的问题!我必须添加这两行:



在app / gradle.build中:

  compile'c​​om.android.support:multidex:1.0.1'

在Manifest文件:

  android:name =android.support.multidex.MultiDexApplication

我从这个问题中获得了这个结果:

未找到类com.google.firebase.provider.FirebaseInitProvider

I've tried again and again to fix this problem, but none of the solutions proposed in the other questions worked for me. After merging my code with my teammates' code, I haven't been able to run my app due to this bug. I've cleaned and rebuilt my project multiple times, but the error still keeps coming up:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

I've tried fixing gradle warnings, updating gradle compile library statements, and putting this flag in my default config:

multiDexEnabled true

The only fix that produced something different was the above flag, which allowed me to actually run the app, but then a different run-time error occurs:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.aaronliang.flow_v1, PID: 11780 java.lang.RuntimeException: Unable to get provider >com.google.firebase.provider.FirebaseInitProvider: >java.lang.ClassNotFoundException: Didn't find class >"com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip >file "/data/app/com.example.aaronliang.flow_v1->177.apk"],nativeLibraryDirectories=[/data/app->lib/com.example.aaronliang.flow_v1-177, /vendor/lib, /system/lib]]

Here are my current gradle build files:

Project build:

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

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.google.gms:google-services:3.1.0'

        //classpath 'com.android.tools.build:gradle:2.3.3'
        //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 {
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
    }
}

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

App build:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        multiDexEnabled true
        applicationId "com.example.aaronliang.flow_v1"
        minSdkVersion 15
        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'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.google.firebase:firebase-firestore:11.6.0'
    compile 'com.google.firebase:firebase-auth:11.6.0'
    compile 'com.google.firebase:firebase-core:11.6.0'
    compile 'com.google.android.gms:play-services:11.6.0'
    compile 'com.github.woxthebox:draglistview:1.5.0'
    //compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    compile 'com.jjoe64:graphview:4.2.1'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.1'
            }
        }

    }
}

Any help would be appreciated, because this project's due soon!

解决方案

Ok, I managed to fix my problem! I had to add these two lines:

In app/gradle.build:

compile 'com.android.support:multidex:1.0.1'

In Manifest file:

android:name="android.support.multidex.MultiDexApplication"

I obtained this from this question:

Didn't find class "com.google.firebase.provider.FirebaseInitProvider"

这篇关于无法合并Dex错误:Android Studio 3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆