Android Studio Error while compiling an apk - java

I want to create my apk file for my project, but I get the following error:
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 Lcom/google/android/gms/internal/zznf;
This is my Build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.wp.fyriaxis"
minSdkVersion 17
targetSdkVersion 25
versionCode 5
versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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.0.1'
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.android.support:design:25.0.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.google.firebase:firebase-ads:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

Your hint is that Multiple dex files define Lcom/google/android/gms
Meaning some of Google packages are conflicting.
The Firebase and Google play services versions must match

Related

Building an APK generates Error:Execution failed for task

When I try to build with my current gradle.build file, I get an error, then following that my gradle build.
Why is it causing this error?
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzaf$zzd.class
this is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.usmans.videodownloader"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
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:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
// glide
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.io.tools.android.ramiloif.folderchooser:folderchooser-dialog:1.0.6'
I don't know what is causing this. What can I do to solve this issue?
Change and exclude gms from facebook library.
compile ('com.facebook.android:audience-network-sdk:4.+'){
exclude group:"com.google.android.gms"
}
Then clean and rebuild your project.
Hope it works :)

Error: TranformException: java.util.zip.ZipException: duplicate entry:org/apache/http/HttpMessage.class error

In Android studio,for my preliminary test for my app, i build it. After gradle build success, when it is made to run, it throws an error,
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry: org/apache/http/HttpMessage.class
my app:build.gradle file is
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.nxtgn.jaunt"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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:design:25.3.1'
testCompile 'junit:junit:4.12'
compile files('libs/android-async-http-1.4.9.jar')
compile files('libs/httpclient-4.3.3.jar')
compile files('libs/apache-httpcomponents-httpcore.jar')
}
its hard for me to figure out my mistake. Please help me where I went wrong.
In terminal you need to execute in root project folder
./gradlew clean

Build causing java.util.zip.ZipException: duplicate entry error

Many seem to face this problem on Stackoverflow but non had the same problem and solution as I did.
"Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/collections/ArrayStack.class"
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.hey"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
multiDexEnabled true
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
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.facebook.android:facebook-android-sdk:[4,5)'
compile 'commons-validator:commons-validator:1.4.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:design:25.3.1'
compile 'com.aurelhubert:ahbottomnavigation:2.0.6'
testCompile 'junit:junit:4.12'
//compile 'com.roughike:bottom-bar:2.3.1'
//compile 'com.android.support:design:26.0.0-alpha1'
}
I had this error:
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 Lorg/apache/commons/collections/Buffer;
I fixed it using multiDexEnabled true but then the duplicate entry error showed up.
EDIT:
The problem was with commons-validator:commons-validator:1.4.1 but I'm still curious onto why and how to fix this error to still be able to use the validator.
If you're interested I solved the problem by replacing:
compile 'commons-validator:commons-validator:1.4.1'
with:
compile 'commons-validator:commons-validator:1.6'

Couldnt find solution for - Error:Execution failed for task

I have tried everything what i found while googling but still have a mistake.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbut.class
My gradle
apply plugin: 'com.android.application'
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.google.firebase.udacity.friendlychat"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
// FirebaseUI Auth only
compile 'com.firebaseui:firebase-ui-auth:1.2.0'
// FirebaseUI Storage only
compile 'com.firebaseui:firebase-ui-storage:1.2.0'
compile 'com.google.firebase:firebase-storage:10.2.6'
// Single target that includes all FirebaseUI libraries above
compile 'com.firebaseui:firebase-ui:1.2.0'
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
This is because of your "multidex" dependency and "multiDexEnabled true" in debug flavor.

Facebook Audience Network Ad Sdk dependency giving run time error in Android App

While adding below dependency in build.gradle
compile 'com.facebook.android:audience-network-sdk:4.+'
The run project is giving error
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzf.class
App, build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.xyz.abc"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
pickFirst 'META-INF/maven/com.squareup.picasso/picasso/pom.properties'
pickFirst 'META-INF/maven/com.squareup.picasso/picasso/pom.xml'
}
}
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
What can be possible solution for it?
Try this
compile('com.facebook.android:audience-network-sdk:4.13.0')
{
exclude group: 'com.google.android.gms'
}
Update Gradle and Android Studio to latest version and it starts working.

Categories