here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.arefin.lasttrykinvay"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name:'kinvey-android-2.10.5', ext:'aar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile google-http-client-1.19.0.jar
compile google-http-client-android-1.19.0.jar
compile google-http-client-gson-1.19.0.jar
compile google-http-client-jackson2-1.19.0.jar
compile gson-2.1.jar guava-18.0.jar
compile jackson-core-2.1.3.jar
compile java-api-core-2.10.1.jar
compile java-api-core-2.10.5.jar
compile kinvey-android-2.10.5.aar
testCompile 'junit:junit:4.12'
}
And here is the error
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/kinvey/java/AbstractClient$Builder$Option.class
When I remove the
compile 'com.android.support:appcompat-v7:23.1.1'
That above error fixes but other functions dont work properly . Like values/style cant not find
Theme.AppCompat.Light.DarkActionBar
How can I that duplicate entry error ?
Remove the duplicate jars and use only required jar and aar files.
Although the OP didn't write this out, if you look at the comments on the original question, you'll see that they have a number of .jar
library files in the libs
directory, which are all included in the following line:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//...
}
In one of their comments, they list the following files in their libs
directory:
google-http-client-1.19.0.jar
google-http-client-android-1.19.0.jar
google-http-client-gson-1.19.0.jar
google-http-client-jackson2-1.19.0.jar
gson-2.1.jar
guava-18.0.jar
jackson-core-2.1.3.jar
java-api-core-2.10.1.jar
Duplicate!
java-api-core-2.10.5.jar
Duplicate!
kinvey-android-2.10.5.aar
You can clearly see that java-api-core
is included twice, once for the 2.10.1
version and once for the 2.10.5
version. The build system isn't smart enough to only bring one of these in, and it shouldn't have to be. The user should tell the build system which libraries to be included and which version of each to include.
By removing the java-api-core-2.10.1.jar
file from the libs
directory, the error should be resolved.
This might not be the exact problem you're running into but it's likely the result of something similar.
To help avoid these situations, here are a couple of best practices:
compile fileTree...
.Instead of hiding away all the .jar
files that you're including, explicitly state which files you're compiling under dependencies {}
. This will make it easier to see when you have duplicates, conflicts and other issues like this.
.jar
files as much as possible.Although it wouldn't catch this, by using Maven and putting the same dependency twice with different versions it should only resolve one of those dependencies (I think) and avoid a cryptic error like you're seeing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With