BUILD FAILED , Information:Gradle tasks [:app:assembleLegacyRelease] - android

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.

Related

Android Studio APK build error - Multiple dex files define Landroid/support/v4/

//Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.cpsraozan.admission"
minSdkVersion 15
targetSdkVersion 27
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:27.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
}
apply plugin: 'com.google.gms.google-services'
Go to your build.gradle file and add multidexEnable true on defaultConfig.
android {
compileSdkVersion 26
defaultConfig {
targetSdkVersion ..
multiDexEnabled true //add this
}
}
For more information See this
This is kind of NOT straight forward. Most likely you might have added a new dependency or updated a dependency which is causing multiple versions of the same library being added as a dependency.
Check if Android studio is highlighting any lines for this, especially in Gradle files.
Run a dump of all dependencies Gradle is processing using the command
./gradlew -q dependencies app:dependencies
check for conflicting dependencies and fix them.
I was struggling this morning with the same error and the requirement for multiDexEnabled didn't make sense. This is only for large projects with more than 64k methods. I found this solution somewhere on SO, but couldn't find it again. So reposting the answer.

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'?

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

Build Failed 'duplicate entry: com/google/api/client/googleapis/auth/clientlogin/ClientLogin$Response.class

Error description:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/api/client/googleapis/auth/clientlogin/ClientLogin$Response.class
build.gradle code here
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion '23.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.jasp.eventapp"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
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/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.8.2'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.couchbase.lite:couchbase-lite-android:1.4-46'
//compile 'com.google.api-client:google-api-client-android:1.22.0'
//compile 'com.google.api-client:google-api-client-xml:1.22.0'
compile 'com.google.api.client:google-api-client:1.4.1-beta'
compile 'com.google.api-client:google-api-client-jackson2:1.22.0'
compile files('libs/google-api-client-1.5.0-beta.jar')
compile 'com.google.android.gms:play-services:9.2.1'
}
Any version problem in imported libs...?How can I handle this...?I tried by cleaning the project
Build - > Clean
after that rebuild, But no effect...Can any one please help me...
This error occurs when you are using duplicate version of same library, or when you use a library project which has same dependency
compile 'com.google.api.client:google-api-client:1.4.1-beta'
compile 'com.google.api-client:google-api-client-jackson2:1.22.0'
compile files('libs/google-api-client-1.5.0-beta.jar')
these three looks like same library , removing duplicate version of the library should fix your error
I had the same problem with Feign library. Look in the .idea\libraries directory in your project, find the same library with different versions and remove one. It should be help.

How to connect GSON lib in AndroidStudio

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

How to fix duplicate entry ZipException in android?

I am using EBS payment gateway in my android application. EBS includes volley library in its folder. Also I use volley library for my project.So I get an exception like this.
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/android/volley/AuthFailureError.class
And below is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
repositories {
mavenCentral()
}
configurations{
all*.exclude group: 'com.android.volley', module: 'toolbox'
}
defaultConfig {
applicationId "com.example.nivedha.rents"
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 fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile project(':EBS')
}
Help me out to fix this issue..
Do like this :
When you added com.mcxiaoke.volley:library-aar:1.0.0 your some of the dependencies got clashed
So, now what you have to do is
Search CTRL+SHIFT+N in android studio for the class AuthFailureError.class
See which jar contains this and remove it like below (This is just as an example/You have to figure out the duplicate class and manually remove it)
configurations{
all*.exclude module: 'toolbox'
}

Categories

Resources