java.util.zip.ZipException with retrofit 2 - android

I'm having
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
>com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: retrofit2/BuiltInConverters$BufferingResponseBodyConverter.class
I can't understand from where this error come and why
Appaered whe i added gson converter from retrofit2
I already clean the project
my gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//compile files('libs/gson-2.7.jar')
// compile files('libs/okhttp-3.4.1.jar')
//compile files('libs/okio-1.11.0.jar')
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-maps:9.2.1'
testCompile 'junit:junit:4.12'
}

//compile files('libs/gson-2.7.jar')
// compile files('libs/okhttp-3.4.1.jar')
//compile files('libs/okio-1.11.0.jar')
You commented these, but those are still being compiled
compile fileTree(dir: 'libs', include: ['*.jar'])
You need to actually remove the jar files if you do not want to compile them. In other words, make sure you don't have any retrofit related jar files in the libs folder

Remove the jar file retrofit2 in libs

Related

DuplicateFileException

I have tried all type of packagingOptions, but nothing worked. That is why posting a new question with my error.
Error:
Error:Execution failed for task ':ChatOn_Chat:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK org.jivesoftware.smack/version
File1: C:\Users\rashid.android\build-cache\11fbeabe7e4519c3c4539d013b76fb32545ef43d\output\jars\classes.jar
File2: F:\changes SKyCHat\SkyChat\HeyYapp-Android\ChatOn_core\build\intermediates\bundles\default\classes.jar
Dependenies of my Main Project:
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':ChatOn_core')
compile project(':cropper')
compile project(':stickyListHeaders')
compile "com.nostra13.universalimageloader:universal-image-loader:${rootProject.universalImageLoaderVersion}"
compile "com.google.android.gms:play-services:${rootProject.googlePlayServicesVersion}"
compile('de.keyboardsurfer.android.widget:crouton:1.8.4#aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile "com.nineoldandroids:library:${rootProject.nineoldandroidsVersion}"
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.crashlytics.android:crashlytics:1.1.13'
compile 'com.android.support:appcompat-v7:25.3.1'
Dependencies of my other Module:
compile 'io.pristine:libjingle:10839#aar'
compile files('libs/quickblox-android-sdk-chat-3.4.jar')
compile files('libs/quickblox-android-sdk-content-3.4.jar')
compile files('libs/quickblox-android-sdk-core-3.4.jar')
compile files('libs/quickblox-android-sdk-messages-3.4.jar')
compile files('libs/quickblox-android-sdk-videochat-webrtc-3.4.jar')
I just solved my problem. I was using same Jar and Dependency.
1st:
compile files('libs/quickblox-android-sdk-chat-3.4.jar')
2nd:
compile 'com.quickblox:quickblox-android-sdk-chat:3.4'
Thanks everyone!

How to make jar file including extended libraries in android studio

I would like to create a exported jar file in Android studio,
but the problem here, the dependencies of gson , rxjava and retrofit did not include from the jar file, when i imported to other project
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
// API CONNECTION
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.google.code.gson:gson:2.6.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.3.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.2'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'junit:junit:4.12'
}
task deleteJar(type: Delete) {
delete 'libs/logmanagementlib.jar'
}
task createJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('libs/jars/')
include('classes.jar')
rename('classes.jar', 'logmanagementlib.jar')
}
createJar.dependsOn(deleteJar, build)
can you give me a example how to include the compile 'com.google.code.gson:gson:2.6.1?

Getting run time error while generating apk

I have a problem when I try to generate an apk with Android Studio 2.3
I'm getting an error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/antlr/v4/runtime/ANTLRErrorListener.class
I understand that some of my dependencies must implement the same methods, but I can't figure out which one,
Here are my dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.graphql-java:graphql-java:2016-10-19T14-40-14'
compile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'org.altbeacon:android-beacon-library:2.12.2'
compile 'io.fotoapparat.fotoapparat:library:1.4.1'
testCompile 'junit:junit:4.12'
}
Thank you
You can exclude the antlr4 in the dependency with:
compile('com.graphql-java:graphql-java:2016-10-19T14-40-14') {
exclude module: 'antlr4'
}
You can find the related issues here:
https://github.com/graphql-java/graphql-java/issues/225
https://github.com/graphql-java/graphql-java/issues/254

TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/content/res/TypedArrayUtils.class

I have shared graddle Image HereError:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/content/res/TypedArrayUtils.class
This error usually occurs when there is duplication of dependencies in gradle file. Check your app gradle file again, search for duplicate dependencies.
For instance, if google services of version 9.2.0 is added and another google service version for instance say maps is added with version 10.0.0 so here conflict will occur hence resulting with this error
Lİke #Techlnsect mentioned above we need to give direct import, try to remove ++ at the end of compiling element and find suitable for your work
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:cardview-v7:2+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:multidex:1.0.0'
}
I changed it to and problem gone
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.android.support:multidex:1.0.0'
}

How to avoid android.support.v4.app.ActivityCompatHoneycomb has already been added

Hil all,
this my error :
Error:Class android.support.v4.app.ActivityCompatHoneycomb has already
been added to output. Please remove duplicate copies.
and my dependecies are :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.android.support:support-v4:22.0.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.google.android.gms:play-services:7.0.0')
compile 'com.squareup.picasso:picasso:2.5.2'
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/ormlite-android-4.45.jar')
compile files('libs/ormlite-core-4.45.jar')
compile files('libs/jackson-databind-2.1.4.jar')
compile files('libs/jackson-core-2.1.4.jar')
compile files('libs/jackson-annotations-2.1.4.jar')
compile files('libs/httpmime-4.1.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile files('libs/paralloidviews.jar')
compile files('libs/jsr250-api-1.0.jar')
compile project(':volley')
compile project(':Android-RSS-Reader-Library-master')
compile project(':facebook')
compile project(':Forecast')
compile project(':headerListView')
compile project(':library-sliding-menu')
compile files('libs/panoramagl.jar')
compile project(':paymentKit_lib')
compile project(':ProgressWheel-master')
compile project(':UIL_library')
compile files('libs/coverflowlibrary.jar')
}
so where I could find the duplacte copies, can you help me please, I struggle with this error a long time ago !
This is most probably happening because one of your library projects already contains support-v4. Try to remove compile('com.android.support:support-v4:22.0.0') from your dependencies and check. This should solve the problem

Categories

Resources