1

I have a small "hello word" android project. I added two AAR files to my android project using File->New->new Module->import .jar/.aar package.Then I add module dependancy to my project for both AAR files using Project structure.

Suppose that two AAR files are AAR1 and AAR2. AAR1 contains three jar files JAR1, JAR2,JAR3 and some data. And AAR2 contains two jar files JAR1 and JAR2 (which is already present in AAR1) and some data.

I build the project successfully and run it. Everything works fine.

But now I just put multiDexEnabled true in defaultconfig{} of app's buld.gradle file and got the exception when I run the application. however gradle build is successfull.

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/mp/rt/Mplite/Image$Next.class

I know there is a repetition of JARS in AAR files but without multidex it is working and with multidex it is not working.

This "hello world" application is just for demo purpose. main project in which I have to put these AAR files required multidex.

I have to keep both the AAR files with mutidex true. How can I achieve that?

below is my app's build.gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.s.in.bio"
        minSdkVersion 18
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile project(':AAR1')
    compile project(':AAR2')
    compile files('libs/android-integration-supportv4.jar')

}

below is the application tag of manifest file:

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:name="android.support.multidex.MultiDexApplication"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
Baqir
  • 717
  • 1
  • 7
  • 20
  • show your `build.gradle` – IntelliJ Amiya Nov 30 '16 at 10:53
  • 2
    Possible duplicate of [Android : app loading library at runtime on Lollipop but not IceCreamSandwich](http://stackoverflow.com/questions/32407985/android-app-loading-library-at-runtime-on-lollipop-but-not-icecreamsandwich) – Devrim Nov 30 '16 at 10:54
  • I have updated question with my gradle file @ IntelliJ – Baqir Nov 30 '16 at 11:03
  • Check this https://stackoverflow.com/questions/37460383/android-project-build-successfully-but-ran-failed-with-error-java-util-zip-zipe/37462369#37462369 – Sagar Gangawane Dec 01 '16 at 05:26
  • does not work @sagar – Baqir Dec 01 '16 at 05:57
  • I also tried- compile(project(‘:AAR1')) { exclude module: ‘JAR1.jar' exclude module: ‘JAR2.jar' } but did not work for this case – Baqir Dec 01 '16 at 06:31
  • I tried the link that you have provided to me @DevrimTuncer but it also did not work so I dont think its a duplicate – Baqir Dec 01 '16 at 06:47
  • The dependencies are duplicate so exclude that library see this link http://stackoverflow.com/questions/30648172/gradle-library-duplicates-in-dependencies – Sagar Gangawane Dec 01 '16 at 10:24
  • nothing is working out for this case . I dont think its a duplicate question – Baqir Dec 01 '16 at 12:23

0 Answers0