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>