Multiple dex files define android/support/annotation/AnimRes - android

When I`m tring to run my app, I receive the following error:
app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:preDexDebug
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.8.0_05\bin\java.exe'' finished with non-zero exit value 2
The content of the gradle script is:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
minSdkVersion 10
targetSdkVersion 22
versionCode 289
versionName "2.2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles 'proguard-android.txt', 'proguard-rules.txt'
}
debug {
debuggable true
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile('com.facebook.android:facebook-android-sdk:3.23.1') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile('com.crashlytics.sdk.android:crashlytics:2.3.1#aar') {
transitive = true;
}
compile project(':UtilsLibrary')
compile project(':NumberPickerLibrary')
compile project(':drag-sort-listview-lib')
compile project(':GoogleAPI Library')
compile project(':MenuDrawerLibrary')
compile project(':IOLibrary')
compile project(':AR Library')
compile project(':GoogleLicense')
compile project(':android-maps-utils-library')
}
I`m sure that somehow I added twice an of the google libraries.
Thanks.

check the other modules, which are compiled for this module.
The best way to see what is contained as dependencies is to use gradlew.
see here how to generate the dependencie three.
now you have to look with the three where the other google librarie is.

Related

Not able to add gms and FCM dependencies

I'm new to android. I'm building an App that requires Map as well as FCM. So to customize markers and set latitude and langitude I'm using gms.
This is my app level gradle build file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
}
apply plugin: 'com.google.gms.google-services'
and the below is my project level gradle build file.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
So when I include both the following dependencies in app level gradle file.
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
I'm getting the following error while running the application.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/internal/zzab;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command 'C:\Program
Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 20.671 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
But when I remove the firebase-messaging dependency it's working. Please help. Thanks in advance
In your gradle use same version of Gms and firebase dependencies.
And as you are only using Google map , no need to import the whole library, use only the map selective portion.
com.google.firebase:firebase-messaging:10.2.1
com.google.android.gms:play-services-maps:10.2.1
in your code:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
com.google.firebase:firebase-messaging:10.2.1
com.google.android.gms:play-services-maps:10.2.1
}

During Android Firebase Admob Integration i getting the error Error:Execution failed for task ':app:transformClassesWithDexForDebug'

I'm having trouble while compiling my project and getting the following Exception please help me out.
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.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_65\bin\java.exe'' finished with non-zero exit value 1
my app.build gradle file code is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "my.appid"
minSdkVersion 15
targetSdkVersion 24
versionCode 2
versionName "1.0.1"
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:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.android.support:palette-v7:24.1.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.firebase:firebase-ads:9.4.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.android.support:multidex:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
And check my project.gradle file code is:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
It looks like you've found a solution to your issue via multidex, but I wanted to point out something about your build settings. In your build.gradle you list these:
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.firebase:firebase-ads:9.4.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'
You can take out play-services-ads, as it's included with both firebase-ads and play-services. Also, If the only part of Play services you're using is AdMob, you can actually take out play-services, too.
We recently put up a blog post explaining a bit about what's in each of these artifacts, as well:
Importing the Mobile Ads SDK with Firebase
Hopefully that helps sort things out a little bit!

BoofCV gradle building Errors in Android studio

When I integrated BoofCV into Android Studio, the following error happened,
com.android.dex.DexException: Multiple dex files define Lorg/xmlpull/v1/XmlPullParser;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/jdk1.8.0_60/bin/java'' finished with non-zero exit value 2
My build.gradle file is
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.huayu.boofcvandroidstart"
minSdkVersion 15
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile group: 'org.boofcv', name: 'all', version: '0.20'
}
Here's how I handled the issue. Include the BoofCV jars as you originally did. Then add the following to your app/build.gradle
configurations {
all*.exclude group: "xmlpull", module: "xmlpull"
}
That will remove the offending xmlpull. You also might want to include the android module, which isn't part of 'all'.
Here's an example on BoofAndroidDemo
https://github.com/lessthanoptimal/BoofAndroidDemo/blob/master/app/build.gradle
I have used BoofCV in one of my projects. You should add all the other BoofCV jars except the XmlPullParser because this jar conflicts with the already existing XmlPullParser present in Android.
I added BoofCV by downloading all the jars and only including the relevant ones like this:
dependencies {
compile files('libs/BoofCV-android-0.19.jar')
compile files('libs/BoofCV-calibration-0.19.jar')
compile files('libs/BoofCV-feature-0.19.jar')
compile files('libs/BoofCV-geo-0.19.jar')
compile files('libs/BoofCV-io-0.19.jar')
compile files('libs/BoofCV-ip-0.19.jar')
compile files('libs/BoofCV-recognition-0.19.jar')
compile files('libs/BoofCV-sfm-0.19.jar')
compile files('libs/BoofCV-visualize-0.19.jar')
compile files('libs/BoofCV-xuggler-0.19.jar')
compile files('libs/core-0.26.jar')
compile files('libs/ddogleg-0.7.jar')
compile files('libs/georegression-0.8.jar')
compile files('libs/xpp3_min-1.1.4c.jar')
compile files('libs/xstream-1.4.7.jar')
}
Although this is a naive way to add the jars you could just include the relevant jars in the libs folder and add this line:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}

In Android Studio Error:Execution failed for task ':app:dexDebug'

Here i am work on twitter integration (login with twitter) with "Fabric Plugin" in android studio 1.1.0
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/dhruv/Dhruv/sdk/build-tools/21.0.2/dx --dex --no-optimize --output /home/dhruv/FestEvo/app/build/intermediates/dex/debug --input-list=/home/dhruv/FestEvo/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/gson/JsonSerializer;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
This is build.gradle: file
buildscript {
repositories {
// jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories{
flatDir{
dirs 'libs'
}
//jcenter()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
defaultConfig {
applicationId "com.festevo.devtesting"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile 'com.android.support:appcompat-v7:21.0.3'
//compile 'com.spotify.sdk:spotifysdk:1.0.0-beta6#aar'
compile 'com.spotify.sdk:spotifysdk:1.0.0-beta8#aar'
// NOTE: Version must match!
// compile 'com.android.support:support-v4:+'
compile project ('libraries:FacebookSDK')
compile project ('libraries:simple-crop-image-lib')
compile project ('libraries:SlidingMenu')
compile project ('libraries:nineoldandroids')
compile project ('libraries:google-play-services_lib')
compile('com.twitter.sdk.android:twitter:1.3.2#aar') {
transitive = true;
}
}
Please suggest me how to solve my problem thanks you in advance:)
Had this error as well. The key is here: "Multiple dex files define Lcom/google/gson/JsonSerializer;"
Most likely you are referencing more than one version of gson in your app. So you can right click on your Project Module -> Open Module Settings -> Dependencies tab and any remove any extra gson versions.
If you want a clearer picture, you can go into terminal in Android Studio and do grep -r gson to see all references.

UNEXPECTED TOP-LEVEL EXCEPTION when adding play-services

I have a project where I need to use the Google play service libary. But when I add it to my dependencies i get the following error:
UNEXPECTED TOP-LEVEL EXCEPTION
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Eclipse\adt-bundle-windows-x86_64-20140702\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\Reigstad\Documents\secret-tyrion-android\Tyrion\app\build\intermediates\dex\debug --input-list=C:\Users\Reigstad\Documents\secret-tyrion-android\Tyrion\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:283)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)>
My build.gradle looks like this:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'org.immutables:gson:1.1.3'
compile 'org.parceler:parceler:0.2.15'
compile 'com.google.android.gms:play-services:6.5.87'
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.tyrion.tyrion"
minSdkVersion 13
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
}
repositories { mavenCentral()}
I have tried all the solutions that I could find, but none of them seems to work for me. My project works fine, its just when I add the libary it wont work.
Hope you guys can help.
You may hitted the 65k methods limit. To use Google Play Services with more granularity, follow this guide, you can use only parts that you want. Probably this will fix your problem

Categories

Resources