Relm Relm - 1 month ago 22
Android Question

Android Studio Gradle errors after updating to 9.4.0

After updating to the new Firebase version, I'm getting the following errors. I've been searching around, and apparently I have to remove some jar files, but I can't seem to understand where to remove these files that are causing conflicts.

The errors are as follows.

Error:Uncaught translation error: java.lang.IllegalArgumentException:
already added: Lcom/google/android/gms/internal/zzml;

Error:Uncaught translation error: java.lang.IllegalArgumentException:
already added: Lcom/google/android/gms/internal/zzmm;

Error:Uncaught translation error: java.lang.IllegalArgumentException:
already added: Lcom/google/android/gms/internal/zzmn;

Error:Uncaught translation error: java.lang.IllegalArgumentException:
already added: Lcom/google/android/gms/internal/zzmo;

Error:Uncaught translation error: java.lang.IllegalArgumentException:
already added: Lcom/google/android/gms/internal/zzmp;

Error:Uncaught translation error: java.lang.IllegalArgumentException:
already added: Lcom/google/android/gms/internal/zzmq;

Error:Uncaught translation error: java.lang.IllegalArgumentException:
already added: Lcom/google/android/gms/internal/zzmr;

Error:7 errors; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.



com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process


Gradle File

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.loopj.android:android-async-http:1.4.9'
///firebase////
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.google.firebase:firebase-crash:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.firebase:firebase-invites:9.4.0'
compile 'com.google.android.gms:play-services-appindexing:9.4.0'

//# Single target that includes all FirebaseUI libraries
compile 'com.firebaseui:firebase-ui:0.4.0'
compile 'joda-time:joda-time:2.9.4'

compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.1.0'

compile 'org.apache.commons:commons-lang3:3.4'

//compile 'io.github.rockerhieu:emojicon:1.4.1'

compile 'com.github.lzyzsd:circleprogress:1.1.0@aar'
}
apply plugin: 'com.google.gms.google-services'


Here's the Project Gradle.

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

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

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

allprojects {
repositories {
jcenter()
}
}

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

Answer

Seeing that you have many dependencies, I thought this maybe related to MultiDex problem which means your project has more than 64K methods. So you need to enable MultiDex in order to have more than 64k

You can enable it by adding the following to the module-level build.gradle

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

And then, create a MultiDexApplication class or extend from MutliDexApplication if you already have an application class.

Don't forget to add it to your Manifest :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>
Comments