For some reason, I am getting a strange error after adding Retrofit to a project that I inherited. If I remove Retrofit, the project builds but If I add it back then the error will re-appear.
How can I fix this issue? any suggestion is welcomed.
Here is the gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.domain.appname"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-config:10.0.1'
compile 'com.google.firebase:firebase-invites:10.0.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.firebaseui:firebase-ui:1.0.1'
compile 'com.firebase:geofire-android:2.1.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.karumi:dexter:2.3.1'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-simplexml:2.1.0'
}
And here is a screenshot of the error message that I am getting.
https://dl.dropboxusercontent.com/u/15447938/downloads/gradle_error.png
I ran gradlew app:dependencies and it was pointing to "UnsupportedClassVersionError"
Caused by: java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
at org.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:71)
at org.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:51)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
This turns out to be some transitive dependencies that Simple XML converter have on Android core. I fixed the issue per this StackOverflow question like this
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile ('com.squareup.retrofit2:converter-simplexml:2.1.0'){
exclude group: 'xpp3', module: 'xpp3'
exclude group: 'stax', module: 'stax-api'
exclude group: 'stax', module: 'stax'
}
Related
I have been trying to add a dependency of com.shamanland:fonticon:0.1.8 but as I add this I get the error
error: duplicate value for resource 'attr/textSize' with config ''.
error: resource previously defined here.
There are too many values with duplication issue to remove the values.
I have tried changing compileSdkVersion and targetSdkVersion to 25 but this did not help either.
I tried to use exclude but I don't know what to exclude exactly. Can anyone help me with this issue? Thank you.
My gradle:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
configurations {
all*.exclude module: 'okhttp'
all*.exclude module: 'okio'
}
compileSdkVersion 27
buildToolsVersion '27.0.2'
defaultConfig {
applicationId "com.abc.def"
vectorDrawables.useSupportLibrary = true
minSdkVersion 17
targetSdkVersion 27
versionCode 15
versionName "1.2.4"
multiDexEnabled = true
}
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
checkReleaseBuilds false
}
minifyEnabled false
}
}
aaptOptions {
cruncherEnabled = false
}
dexOptions {
javaMaxHeapSize "2g"
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
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'
})
compile 'com.android.support:design:27.0.2'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:percent:27.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
provided 'org.projectlombok:lombok:1.16.16'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.8'
annotationProcessor "org.projectlombok:lombok:1.16.16"
compile 'com.google.android.gms:play-services-maps:11.0.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
compile 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.wdullaer:materialdatetimepicker:3.2.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.jd-alexander:library:1.1.0'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.yarolegovich:discrete-scrollview:1.2.0'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.wang.avi:library:2.1.3'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.hedgehog.ratingbar:app:1.1.2'
compile 'com.eftimoff:android-pathview:1.0.8#aar'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
apply plugin: 'com.google.gms.google-services'
compile 'com.stone.vega.library:VegaLayoutManager:1.0.1'
compile project(':library')
compile 'me.henrytao:smooth-app-bar-layout:24.1.0.0'
compile project(':PayTabs_SDK')
/*----------------payfort sdk------------*/
implementation 'com.victor:lib:1.0.1'
implementation 'com.shamanland:fonticon:0.1.8'
implementation('com.nispok:snackbar:2.11.+') {
// exclusion is not necessary, but generally a good idea.
exclude group: 'com.google.android', module: 'support-v7'
}
implementation 'com.google.guava:guava:18.0'
implementation 'org.bouncycastle:bcprov-jdk16:1.46'
implementation 'commons-codec:commons-codec:1.10'
implementation project(':FORTSDKv1.4.4')
}
It may be due to the implementation of other external dependency. In my case, I try removing the external dependency one by one. Most Probably while adding dependency the same dependency was used on other external dependency. So try removing library dependency one by one and see which was causing problem.
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "[ MY PACKAGE ]"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
android {
useLibrary 'org.apache.http.legacy'
}
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.squareup.picasso:picasso:2.5.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.github.deano2390:android-viewbadger:1.0.0'
compile('com.jakewharton:butterknife:8.6.0') {
exclude module: 'support-compat'
}
compile project(':Library_MobilePaymentSDK')
testCompile 'junit:junit:4.12'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.github.aakira:expandable-layout:1.4.2#aar'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.google.android.gms:play-services:10.0.0'
compile 'com.google.firebase:firebase-messaging:10.0.0'
compile 'com.google.firebase:firebase-core:10.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile 'rongi.rotate-layout:rotate-layout:2.0.0'
compile 'com.roomorama:caldroid:3.0.1'
compile 'com.maksim88:PasswordEditText:v0.9'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'gun0912.ted:tedpermission:1.0.3'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jcmore2.appcrash:appcrash:1.1.0'
compile 'com.github.stfalcon:smsverifycatcher:0.2'
compile 'com.github.javiersantos:BottomDialogs:1.2.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
compile files('libs/mpaysdk-sandbox-1.0.28.jar')
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.jakewharton.butterknife'
this gradle file works in api 21 but when i run on api 19 the following error occured.
the following error occured:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: n.class
plz help me to solve this problem.
Solution#1:
In terminal, You can execute the following command in your root project folder:
./gradlew clean
Solution#2:
If you use Android Studio, then you can do it easily, Go to Menu
Build/Clean Project
It will update old dependencies
Solution#3:
You can add the following section to your build.gradle file:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.****"
minSdkVersion 21
targetSdkVersion 25
versionCode 30
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
signingConfig signingConfigs.config
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
maven { url "https://dl.bintray.com/hani-momanii/maven" }
mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
}
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'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile 'com.android.support:support-vector-drawable:25.0.0'
compile 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'com.googlecode.libphonenumber:libphonenumber:7.0.4'
compile 'com.github.siyamed:android-shape-imageview:0.9.+#aar'
compile 'com.theartofdev.edmodo:android-image-cropper:2.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'org.fusesource.mqtt-client:mqtt-client:1.12'
compile 'com.google.firebase:firebase-messaging:9.6.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I want to use minifyEnabled true and try to generate signed Apk but getting error
Warning:Exception while processing task java.io.FileNotFoundException:
\app\build\intermediates\proguard-rules\release\aapt_rules.txt (The
system cannot find the path specified).
What should I do to avoid this error?
build Clean project.
Go to Android Studio -> File -> Invalidate caches/ Restart
Android Studio "Build" - "Clean project" and the error message should not appear again.
I want to build an APk in Android Studio. If I run the project normally(Run/Run App), there is no problem and I get BUILD-SUCCESSFUL(with some errors). But when I want to build APK through Run/Build APK, unfortunately I get BUILD-FAILED and the following error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/sun/activation/registries/LineTokenizer.class
Here is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId 'com.exp.Artoosh'
minSdkVersion 19
targetSdkVersion 24
versionCode 3
versionName "0.4.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/mimetypes.default'
exclude 'META-INF/mailcap.default'
}
}
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'
})
compile 'com.android.support:multidex:1.0.1'
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'javax.mail:mail:1.4.7'
compile 'com.sun.mail:android-activation:1.5.6'
testCompile 'junit:junit:4.12'
}
Could you please help me and tell me a solution?
I solved it.
The problem is that I used javax.mail and com.sun.mail together. First one is belongs java and second one belongs Android. I deleted javax.mail and added com.sun.mail instead, as you see in the following:
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'
})
compile 'com.android.support:multidex:1.0.0'
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'com.sun.mail:android-mail:1.5.6'
compile 'com.sun.mail:android-activation:1.5.6'
testCompile 'junit:junit:4.12'
}
run this in terminal
./gradlew clean
or
run Build/Clean Project
I just enabled Multidex support for my app and now I am getting this error from my Joda time dependency.
I am also using a library gson-jodatime-serialisers that depends on Joda. Not sure if it's causing the duplicate issue.
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: org/joda/time/base/AbstractDateTime.class
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.wake.social"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
manifestPlaceholders = [ localApplicationId:applicationId ]
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile('com.mikepenz:materialdrawer:2.9.8#aar') {
transitive = true
}
compile 'com.mikepenz.iconics:octicons-typeface:2.2.0#aar'
compile 'com.mikepenz:community-material-typeface:1.0.0#aar'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile('de.keyboardsurfer.android.widget:crouton:1.8.5#aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile 'com.afollestad:material-dialogs:0.7.4.2'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
compile 'com.github.satyan:sugar:1.3.1'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'eu.inloop:easygcm:1.4.0#aar'
compile 'me.leolin:ShortcutBadger:1.1.1#aar'
compile 'com.getbase:floatingactionbutton:1.9.0'
compile 'com.mobsandgeeks:android-saripaar:2.0-SNAPSHOT'
compile 'com.squareup:otto:1.3.7'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.github.navasmdc:MaterialDesign:1.5#aar'
compile 'com.github.traex.rippleeffect:library:1.3'
compile ("com.doomonafireball.betterpickers:library:1.6.0") {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'net.danlew:android.joda:2.7.2'
compile 'com.rengwuxian.materialedittext:library:2.1.3'
compile 'com.android.support:multidex:1.0.0'
compile ''com.fatboyindustrial.gson-jodatime-serialisers:gson-jodatime-serialisers:1.1.0' //this depends on it. Could be causing the problem.'
}
compile ''com.fatboyindustrial.gson-jodatime-serialisers:gson-jodatime-serialisers:1.1.0'
//this depends on it. Could be causing the problem.'
According to mvnrespository.com, this library depends on joda-time itself so it may be a duplicate entry
compile ("com.fatboyindustrial.gson-jodatime-serialisers:gson-jodatime-serializers:1.1.0") {
exclude module: 'joda-time'
}
Should do the trick