Reputation: 12007
I have an Android app that has a targetSdkVersion
of 25
. It runs great on API 21+, however, I am trying to fix it to run on API 19+ (KitKat). My app does use Material Design, which I know was introduced in API 21, however I have seen here that there should be ways to back port it.
However, when I build and run, I am get the error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/activation/MimeTypeParseException.class
when I run on an KitKat emulator.
Has anyone seen this error before when trying to back-version test their apps?
My gradle file has:
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:percent:25.0.0'
compile 'com.android.support:palette-v7:25.0.0'
compile 'org.jetbrains:annotations-java5:15.0'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:support-v13:25.0.0'
What additional information can I provide to help debug this?
Update Full gradle code:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'idea'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/mimetypes.default'
}
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.ohmd.ohmd"
minSdkVersion 19
targetSdkVersion 25
versionCode 10
versionName "2.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
renderscriptTargetApi 25
renderscriptSupportModeEnabled true
}
dataBinding {
enabled = true
}
lintOptions {
abortOnError false
}
dexOptions {
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
compileSdkVersion 25
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
repositories {
jcenter()
maven { url 'http://repo1.maven.org/maven2' }
maven { url "https://maven.java.net/content/groups/public/" }
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
}
configurations.all {
resolutionStrategy {
force 'junit:junit:4.12'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'net.sf.flexjson:flexjson:2.1'
compile('org.apache.abdera:abdera-i18n:1.1.1') {
exclude module: 'support-v4'
}
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.0') {
exclude module: 'support-v4'
transitive=true
}
compile('org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0') {
exclude module: 'support-v4'
}
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:percent:25.0.0'
compile 'com.android.support:palette-v7:25.0.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:support-annotations:25.0.0'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.sun.mail:android-mail:1.5.6'
compile 'com.sun.mail:android-activation:1.5.6'
compile 'com.afollestad.material-dialogs:core:0.9.0.2'
compile 'com.afollestad.material-dialogs:commons:0.9.0.2'
compile 'com.code-troopers.betterpickers:library:3.0.1'
compile 'commons-codec:commons-codec:1.10'
compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2'
compile 'com.joanzapata.iconify:android-iconify-material:2.2.2'
compile 'com.joanzapata.iconify:android-iconify-material-community:2.2.2'
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.github.satyan:sugar:1.5'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
compile 'com.github.boxme:asyncmanager:1.0.0'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'joda-time:joda-time:2.9.5'
compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.github.stfalcon:frescoimageviewer:0.3.1'
compile 'joda-time:joda-time:2.9.6'
compile 'com.liuzhuang.opensource:rcimageview:0.0.2'
compile 'com.uncopt:android.justified:1.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.auto.value:auto-value:1.2'
compile 'com.karumi:dexter:2.3.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.google.auto.value:auto-value:1.2'
compile 'com.googlecode.libphonenumber:libphonenumber:7.2.2'
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
compile 'com.github.nekocode:Badge:1.6.2'
compile 'com.sjl:Foredroid:1.0.0'
compile 'com.kaopiz:kprogresshud:1.0.5'
compile 'com.wang.avi:library:2.1.3'
compile 'kr.pe.burt.android.lib:androidoperationqueue:0.0.2'
apt "com.google.auto.value:auto-value:1.2"
compile 'com.ryanharter.auto.value:auto-value-parcel:0.2.4-rc2'
apt 'com.ryanharter.auto.value:auto-value-parcel:0.2.4-rc2'
compile 'jp.wasabeef:recyclerview-animators:2.2.5'
compile 'me.leolin:ShortcutBadger:1.1.10@aar'
compile 'com.cocosw:bottomsheet:1.+@aar'
compile 'com.github.tajchert:nammu:1.1.1'
compile('com.frosquivel:magicalcamera:5.0.2@aar') {
transitive = false;
}
// Circular progress bar
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.2.0'
// Google Play services (old versions, but they work)
compile 'com.google.android.gms:play-services:6.5.87'
// Secure shared preferences
compile 'online.devliving:securedpreferencestore:0.2.4'
// Included libraries
compile project(':animation-core')
compile project(':animation-abslistview')
compile project(':animation-circular-progress-button')
// Fabic
compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:answers:1.3.10@aar') {
transitive = true;
}
// Segment
compile 'com.segment.analytics.android:analytics:4.+'
// Test components
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support:support-annotations:25.0.0'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile('com.android.support.test.espresso:espresso-intents:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile('com.android.support.test.espresso:espresso-web:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
Update 2
I have been able to repeat this exact error by starting a branch new Android app from Android Studio 2.2.2, and using the above gradle file. So it has seems to have nothing to do with the actual code inside my app (which is not surprising).
Upvotes: 12
Views: 3834
Reputation: 6200
Yesterday, I checked the gradle that I asked for and I removed the following lines compile 'com.sun.mail:android-mail:1.5.6', compile 'com.sun.mail:android-activation:1.5.6'
and it compiled. It has nothing to do with any api levels. This is happening because there is another module apart from the one you removed that uses the same package with same class avax/activation/MimeTypeParseException.class
. Did you add the following in your Application class?
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Upvotes: 2
Reputation: 12007
Solved. The culprits were:
compile 'com.sun.mail:android-mail:1.5.6'
compile 'com.sun.mail:android-activation:1.5.6'
I have no idea why, but removing these two packages allowed the entire app to be run and deployed to < 21 versions of Android.
Upvotes: 6
Reputation: 29794
You need to try using Support Annotations Library instead jetbrains annotation. So change
compile 'org.jetbrains:annotations-java5:15.0'
to
compile 'com.android.support:support-annotations:25.0.0'
Then use,
For @Nullable
annotation:
import android.support.annotation.Nullable;
For @NonNull
:
import android.support.annotation.NonNull;
Addition:
Don't forget to change your buildToolsVersion
, targetSdkVersion
, compileSdkVersion
, and Support Library
to use the same API Level.
UPDATE
You need to remove apt
plugin and use annotationProcessor
as the documentation of android-apt says:
From apt to annotationProcessor
As of the Android Gradle plugin version 2.2, all functionality that was previously provided by android-apt is now available in the Android plugin. This means that android-apt is officially obsolete ;) Here are the steps to migrate:
- Make sure you are on the Android Gradle 2.2 plugin or newer.
- Remove the android-apt plugin from your build scripts
Change all apt, androidTestApt and testApt dependencies to their new format:
dependencies { compile 'com.google.dagger:dagger:2.0' annotationProcessor 'com.google.dagger:dagger-compiler:2.0' }
Also remove apt plugin from your build.gradle i.e:
apply plugin: 'com.neenbedankt.android-apt'
Remove duplicate entry of joda-time, use only one of them:
compile 'joda-time:joda-time:2.9.5'
compile 'joda-time:joda-time:2.9.6'
Suggestion:
You need to remove some library which have a kind of similar purpose like these:
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.liuzhuang.opensource:rcimageview:0.0.2'
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
Pick just one that really suitable for your need. Don't waste your precious time to check for all of them.
Also, you need to pick only one the following Image Library:
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.stfalcon:frescoimageviewer:0.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
Upvotes: 1
Reputation: 91
You can't add two support libraries as they overlap each other. Just use one: support-v4.
Upvotes: 1