app:transformClassesWithJarMergingForRelease' while generating release apk - android

Hello I have developed one app and its completed.Now i am tryting to create release apk but i am getting following exception
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/HttpMessage.class
My app build.gradle is as follows
I am not getting why the error is occured in my app.debug app is running perfectely.I am getting error while creating release apk
apply plugin: 'com.android.application'
repositories { flatDir {
dirs 'libs' }
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
dexOptions {
javaMaxHeapSize "4g" // 2g should be also OK
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'org/apache/http/entity/mime/version.properties'
exclude 'META-INF/maven/org.apache.httpcomponents/httpmime/pom.properties'
exclude 'META-INF/maven/org.apache.httpcomponents/httpmime/pom.xml'
}
defaultConfig {
applicationId "com.XXXX.XXXX"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile(name: 'peb-lib', ext: 'aar')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.android.gms:play-services-safetynet:8.3.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.google.android.gms:play-services-analytics:7.3.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.daimajia.androidanimations:library:1.0.3#aar'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.github.bluejamesbond:textjustify-android:2.1.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.d-max:spots-dialog:0.4#aar'
compile 'com.vlonjatg.android:app-tour:1.0'
compile 'com.mobsandgeeks:android-saripaar:1.0.3'
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'org.jsoup:jsoup:1.8.3'
compile 'me.relex:circleindicator:1.2.1#aar'
compile 'it.sephiroth.android.library.imagezoom:imagezoom:+'
}
Please give solution because i want to publish app on playstore.Thanks in advance

You are using two distinct aar or jar dependencies which includes the apache http client. That is your problem. There are some ways to inspect the content of the jar or aar file like jadx, but since you are a beginner a trail and error way should be fine too.
So first if you don't have jar dependencies please remove this line:
compile fileTree(dir: 'libs', include: ['*.jar'])
Now exclude the apache classes from your dependencies for example:
compile 'com.squareup.retrofit:retrofit:1.9.0'
needs to be converted to:
compile('com.squareup.retrofit:retrofit:1.9.0') {
exclude module: 'httpclient'
}
If it still not compile try the next dependency and so on. That should remove the duplicate classes.
Good luck!

Related

Not able to generate signed apk? [DuplicatePlatformClasses error occured]

I am getting this error,
Error: xpp3 defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]
while generating signed apk. How can i solve this problem. Please help me!!
App Gradle,
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.casperon.app.rydepass"
minSdkVersion 17
targetSdkVersion 26
versionCode 17
versionName "4.2"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
cruncherEnabled = false
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':slideDateTimePicker')
compile project(':CountryCodePicker')
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'com.android.support:multidex:1.0.3'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.github.ybq:Android-SpinKit:1.1.0'
compile 'com.squareup:android-times-square:1.6.5#aar'
compile 'com.google.android.gms:play-services:11.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.d-max:spots-dialog:0.7#aar'
compile 'com.android.support:support-annotations:24.0.0'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.github.paolorotolo:expandableheightlistview:1.0.0'
compile 'com.github.ganfra:material-spinner:1.1.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'com.googlecode.libphonenumber:libphonenumber:8.7.0'
compile 'com.github.jakob-grabner:Circle-Progress-View:v1.2.2'
compile 'me.drakeet.materialdialog:library:1.2.2'
compile 'com.wang.avi:library:1.0.1'
compile 'com.android.support:design:24.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.prolificinteractive:material-calendarview:1.4.2'
compile 'org.igniterealtime.smack:smack-android:4.1.0-rc1'
compile 'org.igniterealtime.smack:smack-tcp:4.1.0-rc1'
compile 'org.igniterealtime.smack:smack-im:4.1.0-rc1'
compile 'org.igniterealtime.smack:smack-extensions:4.1.0-rc1'
compile 'net.hockeyapp.android:HockeySDK:3.5.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
compile 'org.jsoup:jsoup:1.8.3'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.crazy1235:RichEditText:v2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'com.squareup:android-times-square:1.6.5#aar'
//noinspection DuplicatePlatformClasses
/* compile 'org.apache.httpcomponents:httpclient:4.5'*/
'org.apache.httpcomponents:httpclient:jar:4.5.6'
configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}
Try this,
configurations {
all*.exclude group: 'xpp3', module: 'xpp3'
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
I had similar problem. Apache library had been used in whole project and I couldn't exclude this library. Today I tried using jar file instead and it worked. You can download apache http library jar files from here:
https://jar-download.com/artifacts/org.apache.httpcomponents

firebase database error when run app

I try to connect my app to firebase database to receiving a list of data from firebase displayed using recyclerview and cardview, but there are many errors when add Dependencies
I get this error when run app .
The first mistake -
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/firebase/iid/zzc.class
this my app build gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.seu.hh.mm"
minSdkVersion 14
targetSdkVersion 26
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:appcompat-v7:23.0.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.firebase:firebase-client-android:2.4.0'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.firebaseui:firebase-ui-database:2.1.1'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
apply plugin: 'com.google.gms.google-services'
this my build gradle project
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
please help me :(
how can solve this problem and make app run
You are mixing compile 'com.firebaseui:firebase-ui-database:2.1.1' with compile 'com.google.firebase:firebase-database:10.0.1' and that's why you have a duplicate.
So first off all you need to remove this line of code:
compile 'com.firebaseui:firebase-ui-database:2.1.1'
Change this lines of code:
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
with
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-crash:11.0.1'
compile 'com.google.firebase:firebase-storage:11.0.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
In this way you'll have the lates versions.

Gradle Errors After Adding Retrofit

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'
}

Android: Error:Execution failed for task ':app:dexDebug'

My application gradle file looks like this.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':purpleb2b')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.thomashaertel:multispinner:0.1.1'
compile 'com.itextpdf.tool:xmlworker:5.5.8'
compile 'com.google.android.gms:play-services:8.4.0' }
When I added the last library (Play services) it gave me the below error.
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
The purpleb2b is a custom library for the project and its dependencies are as follows
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'de.greenrobot:greendao:2.0.0'
compile 'com.google.code.gson:gson:2.4'
compile 'me.neavo:volley:2014.12.09'
compile 'org.apache.httpcomponents:httpmime:4.3.1'
compile 'org.apache.httpcomponents:httpcore:4.3.1'
compile 'itext:itext:1.3.1'
compile 'org.json:json:20151123'
compile 'com.opencsv:opencsv:3.6'
compile 'org.apache.httpcomponents:httpclient:4.5'
}
If I remove play services everything works fine.
Could you please help me resolving this issue...
It's because play services causes 65536 methods error. Try to use particular services that you need. Full overview of libraries you can find there
Simple in your gradle file add these ...
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
// add dexOptions
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
// Add
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
provided fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.parse:parse-android:1.11.0'
// add multidex dependency
compile 'com.android.support:multidex:1.0.1'
}
reference: Error:Execution failed for task ':app:dexDebug' error in my project while I added new dependency

Multidex duplicate entry with Joda Time

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

Categories

Resources