4

Hello Everyone i have one issue on generate signed apk with android studio.

I have search a lot on this but did't find working solution in my case, iknow this is the issue related to duplicate class entry but can anyone tell me which i need to exclude.

I try following thing but that's not working.

 {
    exclude group: 'com.payu.custombrowser', module: 'customBrowser'
 }

This is the error which i'm getting while generate signed apk

Error:Execution failed for task ':transformClassesWithJarMergingForRelease'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/payu/custombrowser/BuildConfig.class

Following is my build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId "company.app.appname"
    minSdkVersion 9
    targetSdkVersion 23
    multiDexEnabled true

}

aaptOptions {
    useNewCruncher false
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        zipAlignEnabled true
    }
}
}

dependencies {

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

compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':hellochartslibrary')
compile project(':customBrowser')
compile project(':facebook')


compile 'com.android.support:support-v4:23.3.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:appcompat-v7:23.3.0'

I don't have any idea what i have to exclude for resolve this does anyone knows kindly help me.

EDIT NOTE:

If i directly run the app means without generate signed apk than its work fine there is no error log but it show me only when i'm trying to generate signed apk

Ajay Pandya
  • 2,417
  • 4
  • 29
  • 65
  • Try running a clean build. http://stackoverflow.com/questions/33209631/errorexecution-failed-for-task-apptransformclasseswithjarmergingfordebug – razzledazzle Apr 16 '16 at 16:54

1 Answers1

1

You're already referring to those jar files with the compileTree directive and therefore probably don't need all those compile files entries.

Also, compile 'com.google.android.gms:play-services:8.4.0', you're including the entire Play Services, there are modular version of those which might help avoid MultiDex in the first place.

razzledazzle
  • 6,900
  • 4
  • 26
  • 37
  • After removing all jar dependency and removing analytics dependency with project rebuild still same error occurred dude any thing else can i do ? I Edit my question after your suggestion and trying – Ajay Pandya Apr 16 '16 at 10:12
  • The error has detected some duplication in the `customBrowser` module. Check if that's already been included as a jar or maybe check that module itself. – razzledazzle Apr 16 '16 at 10:23
  • The module custom browser only use its jar so i'm not able to detect or exclude duplicate entry hope any payu guy help me to resolve this because i try to resolve it by my accountant of payu but not getting any help – Ajay Pandya Apr 16 '16 at 10:24
  • If only that module requires the jar then maybe only include that jar inside the "libs" directory of the module and remove from this. – razzledazzle Apr 16 '16 at 10:29
  • ya its exactly like that there is one jar classes.jar inside custom browser and its only inside that module not for app level gradle https://github.com/payu-intrepos/Android-Custom-Browser/tree/master/libs – Ajay Pandya Apr 16 '16 at 10:32
  • i already try like this way but cant help does it wrong ? exclude group: 'com.payu.custombrowser', module: 'multidex' – Ajay Pandya Apr 16 '16 at 10:33
  • Read this: https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project and only include the ones that you require, not the entire Play Services. This might avoid the MultiDex on the whole. Also, upon reading up on the issues, that Github repo you linked to describes that you only need to include the "aar" file. Additionally, try setting `minifyEnabled` to `true` and configure the `ProGuard` entries. – razzledazzle Apr 16 '16 at 16:47