Android Studio dex.DexException: - android

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?

Related

Android dependency conflict error

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'

Android - duplicate entry: com/google/android/gms/internal/zzafz.class Error

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

Android Error duplicate entry: com/google/android/gms/internal/zzai$zza.class

I am currently having some trouble running my project.
duplicate entry: com/google/android/gms/internal/zzai$zza.class
The error is saying that I have a duplicate dependency, but I can't see a duplicate anywhere!
The error appears on this line of code:
compile 'com.google.android.gms:play-services-ads:8.4.0'
It says that it has found versions 9.8 and 8.4. I only see version 8.4 though.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.tedrasoft.templategoogle"
minSdkVersion 15
targetSdkVersion 23
versionCode=7
versionName="1.6"
multiDexEnabled true
manifestPlaceholders = [manifestApplicationId : "${applicationId}",
onesignal_app_id : "ed282ffa-1e9e-4dd8-9edc-cfdcbe8376bd",
onesignal_google_project_number: "3902815545"]
}
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/chartboost.jar')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.onesignal:OneSignal:2.+#aar'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-analytics:+'
compile 'com.google.android.gms:play-services-location:+'
compile files('libs/jackson-annotations-2.1.0.jar')
compile files('libs/jackson-core-2.1.0.jar')
compile files('libs/jackson-databind-2.1.0.jar')
}
In my case, it's because of the
compile 'com.facebook.android:audience-network-sdk:4.+'
I change it to this:
compile ('com.facebook.android:audience-network-sdk:4.+'){
exclude group:"com.google.android.gms"
}
No more problem!
Make these versions match... so 8.4.0, not + which pulls the latest 9.8 I think, now?
compile 'com.google.android.gms:play-services-analytics:+'
compile 'com.google.android.gms:play-services-location:+'
Also, these are 1) unneccessary lines (because of compile fileTree), and 2) you should make them like the others and not use jar files.
compile files('libs/jackson-annotations-2.1.0.jar')
compile files('libs/jackson-core-2.1.0.jar')
compile files('libs/jackson-databind-2.1.0.jar')
Upgrade google play services (maps, location and gcm) from 9.0.0 to 9.2.0
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.google.android.gms:play-services-maps:9.2.0'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
Then add this dependency:
compile 'com.google.android.gms:play-services-places:9.2.0'

Error:Cannot configure the 'publishing' extension after it has been accessed

Error:Cannot configure the 'publishing' extension after it has been accessed.
I am getting this error after updating my android studio.
this is my app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/universal-image-loader-1.9.5.jar')
compile project(':databaseAutoCompleteLibrary')
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.android.support:gridlayout-v7:23.2.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'milyn:opencsv:1.6'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile project(':MPChartLib')
compile project(':filechooserlibrary')
//compile 'com.android.support:support-v4:18.0.0'
//compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:support-v13:23.2.0'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile project(':Volley')
compile 'com.google.android.gms:play-services:8.4.0'
}
please provide any solution.
I am using volley library.
Thanks.
I have faced the same issue after upgrading to latest studio.
I am not sure about the root cause but what I did is
comment below line from volley build.gradle
apply from: 'bintray.gradle'
As I can see there many project are there in you dependencies.
If possible comment same from all and try syncing again.
Same thing happened to me.
I am not a Gradle expert but my solution was a little bit less drastic. I just edited the bintray.gradle file by moving the line:
apply plugin: 'maven-publish'
just before the publishing action.
This problem seems to be related with this:
https://github.com/researchgate/gradle-release/issues/125
This error comes from volley module, I solved this problem by doing as follows:
open volley module, find bintray.gradle file and change
publishing {
publications {...}
}
to
publishing.publications {...}
then it will work just fine.
I got this now when I introduced a circular dependency among modules inadvertently, in case some one hits it in the future.

TransformException after migrating to Android Studio

I tried to import a working Eclipse Android project to Android Studio. I am working on Mac with the latest version of Android Studio. When I try to build, it keeps on displaying this error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
com/google/api/client/http/AbstractHttpContent.class
The class generating this issue is in the com.google.http-client:google-http-client-gson:1.20.0 library, in the com.google.api.client.http package. I tried many things with the app.gradle file, such as excluding the com.google.api.client.http group but nothing works. Here is my app.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.time2"
minSdkVersion 17
targetSdkVersion 19
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions.encoding = 'ISO-8859-1'
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.1'
compile files('libs/commons-io-2.4.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-http-client-1.18.0-rc.jar')
compile files('libs/google-http-client-android-1.18.0-rc.jar')
compile files('libs/google-oauth-client-1.18.0-rc.jar')
compile files('libs/httpcore-4.3.3.jar')
compile files('libs/httpmime-4.3.6.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
compile 'com.stripe:stripe-android:+'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}
You should avoid manually adding in libs to your project.
E.g. change
compile files('libs/commons-io-2.4.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-http-client-1.18.0-rc.jar')
compile files('libs/google-http-client-android-1.18.0-rc.jar')
compile files('libs/google-oauth-client-1.18.0-rc.jar')
compile files('libs/httpcore-4.3.3.jar')
compile files('libs/httpmime-4.3.6.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
to
compile 'commons-io:commons-io:2.4'
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.http-client:google-http-client:1.18.0-rc'
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client:1.18.0-rc'
compile 'org.apache.httpcomponents:httpcore:4.3.3'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.google.code.findbugs:jsr305:1.3.9'
Please verify that these are the correct packages. Let us know what you find after updating?
The library 'com.google.http-client:google-http-client-gson:1.20.0' is composed of the following nine modules:
google-http-client
google-http-client-android
google-http-client-appengine
google-http-client-xml
google-http-client-protobuf
google-http-client-jdo
google-http-client-jackson
google-http-client-jackson2
google-http-client-gson
Some of these e.g. google-http-client is included again in tour dependencies as a jar. Hence the duplicate entry.
Check this link for getting the setup right when using google-http-java-client. It has step by step instruction - Setup Instructions

Categories

Resources