Am getting en error while try to run the project
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$PrintHelperStubImpl.class
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.codecanyon.khalyil"
minSdkVersion 14
targetSdkVersion 25
multiDexEnabled true
ndk {
moduleName "player_shared"
}
dexOptions {
javaMaxHeapSize "4g"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
jni.srcDirs = []
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:10.2.6'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
compile 'com.android.support:multidex:1.0.1'
}
i tried by cleaning the project
Build - > Clean
after that rebuild, But no effect
The i sync and clean the project, still no result.
Finally i click on 'build apk', but the issue still exciting.
Can any one please help me
The problem here is that you have a class that is included in two dependencies. This is most likely the v4 support lib. Check if one of your dependencies dont include the v4 support library which you already include yourself. You can exclude a dependency this way:
compile ('com.somesdk:sdk:1.3.5#aar') {
transitive=true //you dont need this if you use jars or non-aar dependencies
exclude group: 'com.android.support'
}
Related
thanks for your time :)
i'm getting this message after building my game on android studio
Information:Gradle tasks [:app:assembleLegacyRelease]
Error:Execution failed for task ':app:transformClassesWithJarMergingForLegacyRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/ListFragment$1.class
Information:BUILD FAILED
i've used a legacy release so i don't know how to solve this problem to get my apk file
this is the gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
dexOptions{
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 9
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
legacy {
minSdkVersion 9
versionCode 901 // Min API level 9, v01
}
current {
minSdkVersion 14
versionCode 1401 // Min API level 14, v01
}
}
dependencies {
legacyCompile 'com.google.android.gms:play-services:10.0.0'
currentCompile 'com.google.android.gms:play-services:10.2.0'
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.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:support-vector-drawable:25.0.0'
testCompile 'junit:junit:4.12'
}
sourceSets {
main {
jni.srcDirs = []
}
}
}
thank you for your help , this is my first game
So you've four jar files in your libs folder already which includes support v4 jar as well. Here are the jar files you have in your libs folder as far as I know from your comment.
dagger 1.2.2.jar
javax.inject -1.jar
nineoldandroids-2.4.0.jar
support v4-19.0.1.jar
The error message clearly shows that there's duplicate entry for a support v4 jar.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/ListFragment$1.class
So you need to remove the support v4-19.0.1.jar from your libs folder as you already have a support v7 included in your build.gradle file which has a different version. So you might consider adding this section in your build.gradle file just before your dependencies section.
configurations.all {
resolutionStrategy {
force 'com.android.support:design:25.3.1'
force 'com.android.support:support-v4:25.3.1'
force 'com.android.support:appcompat-v7:25.3.1'
}
}
You might also consider removing compile 'com.android.support:appcompat-v7:25.0.0' from your dependencies as well.
You are having ListFragment class in your project, that is conflicting with ListFragment class provided by Android Fragments pre-defined class. Please refractor your own ListFragment class. That should solve the error.
When I add in gradle compile 'com.google.code.gson:gson:2.2.4'
I have this problem
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/gson/JsonSerializer;
Error: Execution failed for
task':app:transformClassesWithDexForDebug'.>
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
java.lang.UnsupportedOperationException
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "com.jsonmyapp.ars.gson_4"
minSdkVersion 14
targetSdkVersion 22
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:22.0.0'
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.2.4'
}
its not GSON problem, try this
First try this to clean and rebuild your project.
Then open File --> Invalidate Caches / Restart , Click on the blue button Invalidate Caches / Restart.
If this didn't work with u try this solution:
1- add to your
build.gradle(Module.app)
defaultConfig {
multiDexEnabled true
}
2- add this in dependencies:
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
2- In manifest file add this
<application android:name="android.support.multidex.MultiDexApplication">
It works with me Correctly.
And I think the Problem is that you are using a lot of Libraries in the Gradle ,You might have exceeded the 64K Reference Limit.
You need to enable multiDex
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
// also add this in your android block. This is use for multidex
dexOptions {
preDexLibraries = false
incremental true
javaMaxHeapSize "4g"
}
More info on multidex:
Android MultiDex Page
Configure MultiDex
After changing minimum sdk to 16 i've got that error
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/graphics/drawable/DrawableCompatHoneycomb.class
this is my build.gradle (app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.nicoleiesperida.crazyjeepney"
minSdkVersion 16
targetSdkVersion 23
multiDexEnabled true
ndk {
moduleName "player_shared"
}
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Application.mk'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
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')
compile files('libs/support-v4-19.0.1.jar')
compile 'com.facebook.android:facebook-android-sdk:4.+'
}
The same class is being provided by two different dependencies. run
gradle app:dependencies
or
./gradlew app:dependencies
where app is the app project name. Then locate the support v4 package and exclude it from the dependency. Probably it's facebook.
When I sync the project everything is ok, but when I try to run I've got this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: dagger/Provides.class
Here is my app build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "appID"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
apt 'com.google.dagger:dagger-compiler:2.5'
compile 'com.google.dagger:dagger:2.5'
provided 'javax.annotation:jsr250-api:1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile('com.sumup:merchant-sdk:1.61.0#aar') {
transitive = true
}
}
If I run without compile 'com.google.dagger:dagger:2.5' it is success compiled.. please help.
UPDATE:
It looks like sumup sdk is not compatible with dagger 2.+.
So I have downgrade to dagger 1.+ and it is working ok. No other issues appeared until now.
Before downgrading, would you consider trying replacing compile 'com.google.dagger:dagger:2.5' with the following:
compile ('com.google.dagger:dagger:2.0') {
exclude group: 'javax.inject'
}
This will exclude the duplicate class.
I had the similar issue when we switched to Dagger.
We use same package names in different artifacts for the #Component and #Module classes and the Dagger generated the same Dagger...Component.java file in every artifact where we use the same package.
After we moved the components into unique packages in every artifacts, the problem was solved with it.
im currently trying to add gebish into my project. I added the dependencies in my build.gradle, but it says :
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/services/org.codehaus.groovy.transform.ASTTransformation
File1: C:\Users\Muco\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy-all\2.4.5\1730f61e9c9e59fd1b814371265334d7be0b8d2\groovy-all-2.4.5.jar
File2: C:\Users\Muco\.gradle\caches\modules-2\files-2.1\org.gebish\geb-ast\0.13.1\ad8ac4809edf1964636ca2817e48d447c4c0c15b\geb-ast-0.13.1.jar
File3: C:\Users\Muco\.gradle\caches\modules-2\files-2.1\org.gebish\geb-implicit-assertions\0.13.1\ecfb15862e11eaa6b7e1b8179dc60621ae0ff5a\geb-implicit-assertions-0.13.1.jar
I often had "duplicate" problems, but i can't solve this one. What's the best i can do in this kind of situations? I mean i just do what the Doc says and copy-paste, but i get these errors.
build.gradle
apply plugin: 'com.android.application'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.muco.staemme"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile "org.gebish:geb-core:0.13.1"
compile "org.seleniumhq.selenium:selenium-firefox-driver:2.52.0"
compile "org.seleniumhq.selenium:selenium-support:2.52.0"
}
I just had to add
android.packagingOptions {
exclude 'META-INF/services/org.codehaus.groovy.transform.ASTTransformation'
exclude 'META-INF/LICENSE.txt'
}
and now it works.