skip to Main Content

I’m trying to set up proguard to avoid issue 64k methods when i’m working with Dagger 2 + Data Binding.

And I get this issue after many optimize lines in Proguard :

    Copying resources from program jar [appbuildintermediatesexploded-aario.fabric.sdk.androidfabric1.3.14jarsclasses.jar] (filtered)
  Copying resources from program jar [.gradlecachesmodules-2files-2.1com.parse.boltsbolts-android1.4.0cc174c559b5177982887bf6e1b76003aebad9516bolts-android-1.4.0.jar] (filtered)
  Copying resources from program jar [appbuildintermediatesexploded-aarcom.google.firebasefirebase-common9.4.0jarsclasses.jar] (filtered)
  Copying resources from program jar [appbuildintermediatesexploded-aarcom.android.supportsupport-media-compat24.2.1jarslibsinternal_impl-24.2.1.jar] (filtered)
  Copying resources from program jar [appbuildintermediatesexploded-aarfr.tvbarthel.blurdialogfragmentlib3.0.2jarsclasses.jar] (filtered)
  Copying resources from program jar [appbuildintermediatesexploded-aarcom.crashlytics.sdk.androidbeta1.2.2jarsclasses.jar] (filtered)
  Copying resources from program jar [appbuildintermediatesexploded-aarcom.google.android.gmsplay-services-basement9.4.0jarsclasses.jar] (filtered)
Warning: Exception while processing task java.io.IOException: Can't write [appbuildintermediatestransformsproguardjapandebugjars31fmain.jar] (Can't read [appbuildintermediatesexploded-aarcom.google.android.gmsplay-services-basement9.4.0jarsclasses.jar(;;;;;;**.class)] (Duplicate zip entry [com/google/android/gms/common/internal/c.class == classes.jar:com/google/android/gms/common/internal/zzab.class]))
:app:transformClassesAndResourcesWithProguardForJapanDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForJapanDebug'.
> java.io.IOException: Can't write [appbuildintermediatestransformsproguardjapandebugjars31fmain.jar] (Can't read [appbuildintermediatesexploded-aarcom.google.android.gmsplay-services-basement9.4.0jarsclasses.jar(;;;;;;**.class)] (Duplicate zip entry [com/google/android/gms/common/internal/c.class == classes.jar:com/google/android/gms/common/internal/zzab.class]))

I research some articles and know it might be related to Duplicated jar issue, but I don’t know where to set exclude correctly.

Anyone who knows, please help me solve it.

Thank you very much,

p/s :

This is proguard file :

    # Google gms
#-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**

#rx java
-dontwarn rx.internal.util.unsafe.**

#picaso
-dontwarn jp.wasabeef.picasso.transformations.gpu.**

#graphview
-dontwarn com.jjoe64.graphview.helper.**

# Ignore warnings: We are not using DOM model
-dontwarn com.fasterxml.jackson.databind.ext.DOMSerializer

# Keep Jackson stuff
-keep class org.codehaus.** { *; }
-keep class com.fasterxml.jackson.annotation.** { *; }

# Keep Retrofit
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
    @retrofit.** *;
}
-keepclassmembers class * {
    @retrofit.** *;
}

# Keep Picasso
-keep class com.squareup.picasso.** { *; }
-keepclasseswithmembers class * {
    @com.squareup.picasso.** *;
}
-keepclassmembers class * {
    @com.squareup.picasso.** *;
}

app.gradle :

    apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 1
        versionName "2.3.6"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    signingConfigs {
        debug {}
        release {}
    }
    buildTypes {
        debug {
            shrinkResources true
            minifyEnabled true
            applicationIdSuffix ".debug"
            signingConfig signingConfigs.debug
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
    // Product flavors
    productFlavors {
        japan {
            applicationIdSuffix ".japan"
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding {
        enabled = true
    }

    retrolambda {
        jvmArgs '-noverify'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }

}

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'
    })
    // Default - Android Component
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:appcompat-v7:24.2.1'
    // Dagger 2
    apt 'com.google.dagger:dagger-compiler:2.6.1'
    provided 'org.glassfish:javax.annotation:10.0-b28'
    compile 'com.google.dagger:dagger:2.6.1'
    // Retrofit2 + Gson
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    // RxJva
    compile 'io.reactivex:rxandroid:1.2.0'
    compile 'io.reactivex:rxjava:1.1.4'
    // Firebase
    compile 'com.firebase:firebase-client-android:2.5.2'
    compile 'com.google.firebase:firebase-messaging:9.4.0'
    // Butter Knife
    apt 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'com.jakewharton:butterknife:8.4.0'
    // Timber
    compile 'com.jakewharton.timber:timber:4.3.0'
    // Picasso
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'jp.wasabeef:picasso-transformations:1.0.5'
    // Custom font : using in XML
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    // Facebook Rebound Animation
    compile 'com.facebook.rebound:rebound:0.3.7'
    // Blur dialog
    compile 'fr.tvbarthel.blurdialogfragment:lib:3.0.2@aar'
    // Twitter api
    compile('com.twitter.sdk.android:twitter:2.1.1@aar') {
        transitive = true;
    }
    // Facebook api
    compile ('com.facebook.android:facebook-android-sdk:4.15.0'){
//        exclude module: 'bolts-android'
        exclude module: 'support-v4'
    }

    compile 'net.qiujuer.genius:blur:1.0.0'

    compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'

    compile project(':CropImage')

    //request permission
    compile 'com.tbruyelle.rxpermissions:rxpermissions:0.7.0@aar'
    //crash report
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }
    compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
}

project app.gradle

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'

        // Dagger 2
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

        //retrolambda
        classpath 'me.tatarka:gradle-retrolambda:3.2.4'

        classpath 'io.fabric.tools:gradle: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.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://dl.bintray.com/l-offshore-team/l-offshore-libs/" }
        maven { url 'https://maven.fabric.io/public' }
    }
}

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

2

Answers


  1. In app.gradle you need to move following entry to the end of file :

    apply plugin: 'com.google.gms.google-services'
    
    Login or Signup to reply.
  2. I had the same issue. For me, the problem was that I also had some other Google Play Services dependency, but with a different version. Once I made sure they have the same version, the issue was solved.

    Hopes this helps someone.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search