3

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!

gameCoder95
  • 349
  • 1
  • 5
  • 19

2 Answers2

2

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"

gameCoder95
  • 349
  • 1
  • 5
  • 19
0

Your minSdk is lower than 20, so you have to add compile 'com.android.support:multidex:1.0.1' to your build.gradle dependencies. Source

sininen
  • 503
  • 1
  • 6
  • 20
  • Invalidate Caches/Restart or clean and rebuild after adding the line didn't help? Try adding this to your `android` tag: `dexOptions { javaMaxHeapSize "4g" }`. Does this help: https://stackoverflow.com/a/41444469 ? – sininen Nov 20 '17 at 20:55
  • Out of curiosity, what does that tag do? – gameCoder95 Nov 20 '17 at 22:07
  • 1
    It sets your maximum available memory to your JVM, 4g means 4 GB. – sininen Nov 21 '17 at 16:47