java.util.zip.ZipException: duplicate entry Android - android

I have been working on a chatting kind of application using xmpp ejabbered. I wanted a signed apk of the app, so i tried getting one but I got the following error. Previously i was getting same error with com.parse library so i removed the library from libs folder and now this error. I searched on net and many people got that error but their libraries are different so I tried implementing that but still wasn't successful.
This is my app level build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "mchat.sunil.com.mchat"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:24.2.1'
compile 'org.igniterealtime.smack:smack-tcp:4.1.0'
compile 'org.igniterealtime.smack:smack-android-extensions:4.1.0'
compile 'com.parse:parse-android:1.13.1'
compile 'org.jitsi:org.otr4j:0.22'
compile 'com.github.siyamed:android-shape-imageview:0.9.3'
compile 'com.google.code.gson:gson:2.7'
compile 'org.simpleframework:simple-xml:2.7.1'
}
configurations {
all*.exclude group: 'xpp3', module: 'xpp3'
}
The error which i'm getting is
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/jxmpp/stringprep/simple/SimpleXmppStringprep.class
Error:Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
Solutions which i tried is excluding it with different libraries one by one.
all*.exclude group: 'jxmpp', module: 'smack-tcp'
all*.exclude group: 'jxmpp', module: 'smack-android-extensions'
all*.exclude group: 'jxmpp', module: 'parse-android'
all*.exclude group: 'jxmpp', module: 'org.otr4j'
but still couldn't find the proper solution. Can anyone help me with this. Any help will be appreciated. Thank you.

Related

How to import org.springframework.data into Android Studio using Gradle

I need the org.springframework.data.geo.Point class in my Spring Android app. I have the spring-android dependency already downloaded here. This does not have the .data section. When I try to use Gradle to import a different library I get duplication file errors. After consulting this link I get errors involving Dex cannot parse version 52 byte code. While reviewing this previous post I read that this wasn't the recommend way of getting rid of these errors.
Is there a spring library that I can import that has the org.springframework.data as well as everything given in the org.springframework.android:spring-android-rest-template:2.0.0.M3 library.
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.avi.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
//pickFirst 'META-INF/spring.schemas'
//pickFirst 'META-INF/spring.tooling'
//pickFirst 'META-INF/spring.handlers'
//pickFirst 'META-INF/spring.factories'
}
}
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.2'
testCompile 'junit:junit:4.12'
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
}
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
Error Message after following this:
Error:Execution failed for task
':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/spring.schemas
File1: C:\Users\Avi.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.0.2.RELEASE\1befa3239976b856202b1735531910a0c2f4e17f\spring-data-commons-2.0.2.RELEASE.jar
File2: C:\Users\Avi.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.0.2.RELEASE\301ee07b390bc8b5691f4206411b49beb06f7ff2\spring-beans-5.0.2.RELEASE.jar
Error Message after following this:
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.

Error while generating a signed apk in Android Studio

I want to generate an apk file out of my project but I keep getting this error while generating the signed apk:
Execution failed for task ':app:transformClassesWithJarMergingForRelease'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$PrintHelperStubImpl.class
I'm searching since 6 hours for a solution now and I have tried nearly everything but I can't fix it. Does anyone know how to fix this?
This is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.pake.lightbulb"
minSdkVersion 14
targetSdkVersion 26
multiDexEnabled true
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.txt'
}
}
sourceSets.main
{
jni.srcDirs=[]
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
}
dependencies {
compile('com.google.android.gms:play-services:+')
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
}
Most probably support-v4 library gets also included via the play-services dependency. To exclude it change the relevant dependency line of your gradle to:
compile('com.google.android.gms:play-services:+')
{
exclude module: 'support-v4'
}
To troubleshoot it more and inspect for other duplicates and conflicts, check the dependency tree command of gradle:
gradle -q dependencies --configuration compile

Android: Error:Execution failed for task app:transformClassesWithPreJackPackagedLibrariesForDebug

I got this error when I tried to run my Android program.
Error:Execution failed for task ':app:transformClassesWithPreJackPackagedLibrariesForDebug'.
java.lang.AssertionError: java.util.zip.ZipException: duplicate entry: jayce/org/hamcrest/BaseDescription.jayce
here is my build.gradle
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.surgical.decision"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}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:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile files('libs/simple-xml-2.7.1.jar')
compile files('libs/log4j-1.2.17.jar')
compile files('libs/pddl4j-3.5.0.jar')
}
I have to enable jackOptions because there are a lot of function that I wrote in Java 8.
I had that same problem. I believe that com.android.support.test.espresso:espresso-core:2.2.2 is compiled with hamcrest and I think that com.android.support:appcompat-v7:25.3.1 also is compiled with hamcrest. I believe the error message is telling you that the hamcrest package is contained in at least two of the compiled jar and it can't resolve the duplicate issue (even though they are the same version). It probably can't resolve the duplicate due to some Jack technicality. To get around the problem, you just need to exclude it from one or the other:
i.e
`androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'org.hamcrest', module: 'hamcrest-core'
})
or if you're not really using espresso-core, just delete the androidTestCompile line altogether.
In my situation, I also had to add:
exclude group: 'junit', module: 'junit'
because I was getting a slightly different error due to the inclusion of two different junit versions conflict.
The best technique for debugging these kinds of errors is by using gradle from a command line.
open command prompt
navigate to project directory (it contains gradlew.bat)
gradlew app:androidDependencies

error while using firebase

When i'm using Firebase I always face this error !
Error:FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: C:\Users\e171x.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2\d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\jackson-core-2.2.2.jar
File2: C:\Users\e171x.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.2.2\3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson-databind-2.2.2.jar
File3: C:\Users\e171x.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.2.2\285cb9c666f0f0f3dd8a1be04e1f457eb7b15113\jackson-annotations-2.2.2.jar
Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
which doesn't allow the emulator to run
my app gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.example.e171x.testingonline"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:24.2.1'
compile 'com.google.firebase:firebase-crash:9.8.0'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.firebase:firebase-client-android:2.3.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
It looks like you are adding one of the JARs, namely jackson-core-2.2.2.jar from multiple modules. If you are using Android Studio, check in build.gradle files of each of your modules to check where the duplication is. You may keep it where it is accessible from all modules based on your dependency chain.
Replace:
compile 'com.firebase:firebase-client-android:2.3.1'
with:
compile('com.firebase:firebase-client-android:2.3.1', {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-bind'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
})
You should not use both the legacy Firebase SDK, com.firebase:firebase-client-android:2.3.1, and the libraries of the new 9.x.x SDK in the same app. They are not compatible and will interfere with each other. Remove com.firebase:firebase-client-android:2.3.1 and read the Firebase Upgrade Guide for tips on code changes.

java.util.zip.ZipException: duplicate entry: com/facebook/ads/AbstractAdListener.class

I am trying to implement facebook mobile ads in an android app. Everything went fine but in build gradle i m getting error.
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry:
com/facebook/ads/AbstractAdListener.class.
And build.gradle codes are
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.mohit.warmodroid.practicefbads"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
multiDexEnabled true
}
}
}
dependencies
{
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile ('junit:junit:4.12'){
exclude group: 'com.facebook.ads', module: 'classes.jar'
}
compile 'com.android.support:appcompat-v7:23.0.1'
compile ('com.android.support:design:23.0.1'){
exclude group: 'com.facebook.ads', module: 'classes.jar'
}
compile('com.facebook.android:audience-network-sdk:4.7.0'){
exclude group: 'com.facebook.ads', module: 'classes.jar'
}
compile 'com.android.support:multidex:1.0.0'
}
I tried everything availble on stackoverflow.com but unable to clear it.
Please help me out.
In the Gradle settings and project configurations there is an old version of AudienceNetwork.jar, existing in the \libs folder. Remove this jar file from \libs and rebuild the project: this should fix the problem.

Categories

Resources