I got this error when I run the code ->
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.>
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/google/android/gms/internal/zzafz.class
I have no idea what does it means and do I fix it. I need your help guys
I have treid several things but nothing really helped, I added "multiDexEnabled true" and that cause to that error.
Before that error O had "android error finished with non-zero exit value 2". After I added "multiDexEnabled true", it gives me this error:
"duplicate entry: com/google/android/gms/internal/zzafz.class Error"
How can I fix it, any help would be appreciated!
this is my Manifest
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.world.bolandian.gpstracker"
minSdkVersion 14
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/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
}
apply plugin: 'com.google.gms.google-services'
remove compile 'com.google.android.gms:play-services-maps:9.6.1' and clean-build the project
You are including both the legacy Firebase API:
compile 'com.firebase:firebase-client-android:2.3.1'
and the new Firebase APIs:
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
They should not be used together. Remove firebase-client-android:2.3.1 and follow the instructions in the Firebase Upgrade guide.
It is also important to use the same versions of Firebase and Play Services libraries. Don't use 9.6.1 of play-services-maps and 9.2.1 of the Firebase libs. The latest versions available are 10.0.1. Consider updating all of your dependencies to use the latest versions.
Update:
I copied the dependencies you posted and was able to reproduce the error. After I replaced the dependencies with these, the error was resolved. Do these not work for you?
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
}
Related
I tried for many hours to find the solution but could not find. My problem is that when I build my Gradle I get two errors. I tried to look at this solution
Dependency conflict error in my Android app which has Android Tests but could still not solve the problem.
Error:Conflict with dependency 'junit:junit' in project ':app'. Resolved versions for app (4.10) and test app (4.12) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'org.hamcrest:hamcrest-core' in project ':app'. Resolved versions for app (1.1) and test app (1.3) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Here's my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "voice.com.topsalai"
minSdkVersion 16
targetSdkVersion 23
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.3-
alpha', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'com.google.android.gms:play-services:10.2.4'
compile 'com.android.support:support-annotations:26.0.0-alpha1'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
How can I solve this?
dont use alpha..or beta.. just use the latest stable one..then please dont mix your android support version.. use same version for all android support
example
compile "com.android.support:appcompat-v7:25.3.1"
compile "com.android.support:cardview-v7:25.3.1"
compile "com.android.support:design:25.3.1"
compile "com.android.support:recyclerview-v7:25.3.1"
compile "com.android.support:support-annotations:25.3.1"
compile "com.android.support:support-v4:25.3.1"
compile "com.android.support:support-v13:25.3.1"
please remove this two dependency
testCompile 'com.android.support:support-annotations:26.0.0-alpha1'
androidTestCompile 'com.android.support:support-annotations:26.0.0-alpha1
I found the solution. By upgrading compileSdkVersion to
compileSdkVersion 25
And then Instead of this
compile 'com.android.support:appcompat-v7:23.1.1'
Only by updating appcompat-v7:23.1.1 did not solve it. I needed theese 3 lines of code.
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'
Randomly got this error during my build (debug or production) in the morning.
com.android.dex.DexException: Multiple dex files define Lcom/crashlytics/android/answers/shim/R
Execution failed for task ':app:transformClassesWithDexForDebug'.
>...
It has been 10hours and I have tried:
1) Updated my Android SDKs
2) Updated my Google Repository
3) Updated everything else as well.
4) Cleaned and Rebuild the project with no errors.
5) Went through my external dependency tree, didn't find any duplicate libraries.
Here is my gradle content:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "######.####"
minSdkVersion 19
targetSdkVersion 25
versionCode 53
versionName "1.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.androidmapsextensions:android-maps-extensions:2.3.0'
compile 'com.google.android.gms:play-services-gcm:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.android.gms:play-services-places:10.2.1'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'org.jsoup:jsoup:1.9.2'
compile 'com.github.lzyzsd:circleprogress:1.1.0#aar'
compile 'com.google.code.gson:gson:2.7'
compile 'io.branch.sdk.android:library:2.+'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-crash:10.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:1.0.1'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.edmodo:rangebar:1.0.0'
compile 'com.appyvet:materialrangebar:1.3'
compile 'com.facebook.fresco:fresco:0.14.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.android.support:recyclerview-v7:25.0.0'
}
apply plugin: 'com.google.gms.google-services'
Running out of ideas and google result pages for a solution. Does anybody experienced find something wrong with the libraries I use or the versions?
Thanks!
remove this line = compile 'com.android.support:design:25.0.0'
if it doesn't work please add
dexOptions {
preDexLibraries = false }
to your build.gradle file
Solution found.
Looking at the error I googled and found this.
Then went to the Branch documentation and found this here which stated:
Note that if you don’t plan to use the Fabric Answers integration, you
can use the following line:
compile ('io.branch.sdk.android:library:2.+') {
exclude module: 'answers-shim'
}
This answers-shim is also in the stacktrace.
I wonder where is that module then duplicated?
I'm trying to implement Google Analytics in my App , but when compiling I get the following error:
Error:Execution failed for task ':app:mergeDebugResources'.
[xml/global_tracker]
C:\Users\Carlos\AndroidStudioProjects\Capstone\SP\Stocks Panel
Lite\app\src\main\res\xml\global_tracker.xml [xml/global_tracker]
C:\Users\Carlos\AndroidStudioProjects\Capstone\SP\Stocks Panel
Lite\app\build\generated\res\google-services\debug\xml\global_tracker.xml:
Error: Duplicate resources
I've tried to run clean project, but I get the same error. I also get the same error if I remove app/build.
Thanks in advance.
UPDATE: build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.carlos.capstone"
minSdkVersion 11
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/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:gridlayout-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:support-annotations:23.1.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'io.reactivex:rxjava:1.1.1'
compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
compile 'com.bignerdranch.android:expandablerecyclerview:2.0.4'
compile 'com.crazyhitty.chdev.ks:rss-manager:0.21'
compile 'com.github.frankiesardo:linearlistview:1.0.1#aar'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.facebook.stetho:stetho-urlconnection:1.3.1'
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.android.support:customtabs:23.0.0+'
compile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
compile 'org.apache.commons:commons-lang3:3.1'
compile 'org.apache.poi:poi:3.14'
compile 'net.sf.supercsv:super-csv:2.4.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
}
This happens when you place a global_tracker.xml in your resources xml folder and in addition to that add apply plugin: 'com.google.gms.google-services' in your build.gradle file. That is mixing the old way of implementing the tracker with the new way of doing things. The solution would be to simply remove the global_tracker.xml from your xml folder, as the google-services plugin will automatically add all the required data from the google-services.json configuration file when building your app.
Also, it's advisable to place the apply plugin: 'com.google.gms.google-services' line at the bottom of your build.gradle after the dependencies section. It's strange, but having it at the top causes errors in some configurations.
In addition, you might see error: cannot find symbol variable global_tracker when trying to build your project, especially if you are converting an older project, and downloaded your google-services.json from your Firebase console while still using it with the older Google Analytics. In that case, open the newly added google-services.json and find "analytics_service" in the "services" object. You will need to add the following:
"analytics_property": {
"tracking_id": "<your tracking id>"
so the entire section looks like this (place your own UA-XXXXXXXX-X tracking ID there):
"analytics_service": {
"status": 2,
"analytics_property": {
"tracking_id": "UA-12345678-9"
}
},
After that make sure to Clean your project and re-sync Gradle before you rebuild. Hope that helps.
I'm getting the following error. I have not tried to solve it the last two days, but nothing had solved the problem.
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: org/apache/http/HttpMessage.class
here is my build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.0'
defaultConfig {
applicationId "com.mycompany.newlogin"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.guava:guava-jdk5:17.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}
please help me with this .thank you in advance.
I too had this Error and i resolved this by removing httpcore
in your build.gradle(app) Remove these lines
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
and then add latest apache library to your build.gradle(app)
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
Have a look at your referenced packages, org.jbundle.util.osgi.wrapped.org.apache.http.client seems to contain at least some classes of httpcore, especially that one mentioned in your error message. So I guess you simply can't and shouldn't use both as dependencies, but only the ones you really need.
The following libraries were causing conflict and i removed it from build.gradle
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
and i left only with :
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
My project is a Chat app that uses Parse. After added other dependencies, this problem started appearing:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-oracle/bin/java'' finished with non-zero exit value 2
Searching here in StackOverflow, some folks told me that it could be the 65K limit from Android.
So, to solve I followed the steps below:
1 - Add Multidex
DefaultConfig {
multiDexEnabled true
}
and
compile 'com.android.support:multidex:1.0.0'
https://developer.android.com/tools/building/multidex.html
2 - Enable Jumbo Mode in Android Gradle Settings
dexOptions {
jumboMode = true
}
I cleaned the project and ran the gradle build. It did not generate any errors. Great! But when I click "Run app" it generates this error below.
Error: Execution failed for task ': app:
packageAllDebugClassesForMultiDex'. > Java.util.zip.ZipException:
duplicate entry: bolts / AggregateException.class
If I remove the dependency 'com.parse.bolts: bolts-android: 1. +' the "Run app" works, but I can not do without the dependency of Parse.
This is my Gradle build script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "br.com.triangulum.mink"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode = true
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile('com.android.support:multidex:1.0.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse*.jar')
compile project('libraries:httprequest')
compile project('libraries:cameralibrary')
compile project('libraries:bgarefreshlayout')
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:design:+'
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.afollestad:material-dialogs:0.7.4.0'
compile 'com.getbase:floatingactionbutton:1.10.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'de.greenrobot:eventbus:2.4.+'
compile'com.edmodo:cropper:1.0.+'
compile 'com.github.ksoichiro:android-observablescrollview:+'
compile 'com.etsy.android.grid:library:1.0.5'
compile('com.mikepenz:actionitembadge:3.0.2#aar') {
transitive = true
}
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'com.android.support:multidex:1.0.+'
}
try to change this:
compile('com.android.support:multidex:1.0.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
To this:
compile('com.android.support:multidex:1.0.0');
the bolds module is used sometimes to fix Duplicated dexLibs
Regards
Your com.facebook.android:facebook-android-sdk:4.1.0 library is messing with parse as both use same bolts-android module internally and having a different version of this module. Try to exclude this module from any of parse or facebook gradle dependency.
compile('com.facebook.android:facebook-android-sdk:4.1.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
I was having the same problem and When I run ./gradlew yourModuleName:dependencies by the terminal, I found exactly which two libraries are messing with each other having a different version of the same module internally.