Adding iTextG jar to Android Studio - android

I'm facing a problem with adding the itextg-5.5.4.jar to my Android project in Android Studio. I copied the jar file to my libs folder and added it as a library.
I can use the classes in my project but when i try to start the app on my device, a UNEXPECTED TOP-LEVEL EXCEPTION occurs.
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/Paule/Documents/Android SDK/sdk/build-tools/android-4.4W/dx --dex --output
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
build.gradle contains the dependencies (there are 14 more jar dependencies, I've removed them for a better overview)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.0'
compile 'com.google.android.gms:play-services-base:6.5.87'
compile files('src/main/libs/itextg-5.5.4.jar')
....
....
}
Does anyone know how to fix that error?

Related

Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION: on importing a eclipse project

I have imported a project in Android Studio. I am attempting to run the code but the app fails with the following errors, not sure what the problem is.
These are the libraries i am using.
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:+'
compile files('libs/android-async-http-1.4.6.jar')
compile files('libs/android-query-full.0.26.8.jar')
compile files('libs/android-viewbadger.jar')
compile files('libs/Android-WebRequest.jar')
compile files('libs/AndroidSwipeLayout-v1.1.6.jar')
compile files('libs/google-api-client-1.20.0.jar')
compile files('libs/google-api-services-bigquery-v2-rev200-1.20.0.jar')
compile files('libs/google-http-client-1.20.0.jar')
compile files('libs/google-http-client-jackson2-1.20.0.jar')
compile files('libs/google-oauth-client-1.20.0.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/Parse-1.9.2.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile files('libs/com-crashlytics-sdk-android_answers-classes.jar')
compile files('libs/com-crashlytics-sdk-android_beta-classes.jar')
compile files('libs/com-crashlytics-sdk-android_crashlytics-classes.jar')
compile files('libs/io-fabric-sdk-android_fabric-classes.jar')
and error i am getting is
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\ch-e01062\AppData\Local\Android\android-sdk\build-tools\23.0.0-preview\dx.bat --dex --no-optimize --output C:\Users\ch-e01062\Downloads\FreeB2\app\build\intermediates\dex\debug --input-list=C:\Users\ch-e01062\Downloads\FreeB2\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/android/gms/analytics/internal/Command$1;
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:502)
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)
i have tried many available solutions but nothing is working.Any help will be appreciated.
After hours with the same problem i found the answer.
The problem is that you have multiple libs with the same classes inside, so the solution would be to either remove the repeating files from one of the libs.
You have to:
Open the lib libGoogleAnalyticsServices.jar with WinRAR, 7Zip or whatever.
Go to com/google/android/gms/analytics/internal and delete the files Command$1.class and Command.class.
In your case you may have to remove other repeating files, not sure because you have many files. Either way, you can also force it to ignore some of those files IF the method above didn't work. Put the following code inside the Android block on your build.gradle file:
defaultConfig {
multiDexEnabled true
}
dexOptions {
preDexLibraries = false
}

Error resolving dependencies with Gradle, in Android project

I have configured the following dependencies in Gradle, inside Android Studio.
compile 'com.google.code.gson:gson:2.2.4'
compile files('libs/android-support-v13.jar')
compile files('libs/apache-mime4j-storage-0.7.2.jar')
compile files('libs/commons-cli-1.1.jar')
compile files('libs/commons-io-1.2.jar')
compile files('libs/httpclient-4.3.4.jar')
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.3.4.jar')
compile files('libs/rabbitmq-client.jar')
compile files('libs/retrofit-1.7.1.jar')
compile files('libs/universal-image-loader-1.9.3-with-sources.jar')
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.google.android.gms:play-services:7.0.0'
But Gradle gives me the following error:
Execution failed for task ':app:dexDebug'.
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\AS sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\ttuser\ASProjects\MyProject\app\build\intermediates\dex\debug --input-list=C:\Users\ttuser\ASProjects\MyProject\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
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)
How can I solve it?
app:dexDebug error in general means that you've tried to link in the duplicate class to your project more than once. So remove your Duplicate Library
I don't know if you figured it out yet, but seeing as all of those are publicly available libraries, I suggest getting rid of the JARs and getting them as a dependency from JCenter/Maven Central. If you are not sure how to do this, here is an example. One library you are using is Retrofit, so you would go to a website like Maven Central (http://search.maven.org/) and search for the library and get the Gradle dependency for your version (http://search.maven.org/#artifactdetails|com.squareup.retrofit|retrofit|1.7.1|jar):
compile 'com.squareup.retrofit:retrofit:1.7.1'
Do this for all of your dependencies. Once you have them set up as Gradle dependencies instead of JARs, you can do what is explained here: https://stackoverflow.com/a/21100040/2245921
Basically, go into your :app folder through a terminal, and run the following:
../gradlew -q dependencies
And Gradle will draw a dependency tree. There you will be able to see duplicate dependencies and more easily deal with them.

Problems adding ListViewAnimations to android project

I'm trying to add the library https://github.com/nhaarman/ListViewAnimations to my android project but I can't get it to work. Syncing gradle works just fine but when compiling I get the following error:
.
.
.
:AoEu:generateDebugSources UP-TO-DATE
:AoEu:compileDebugJava UP-TO-DATE
:AoEu:preDexDebug UP-TO-DATE
:AoEu:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':AoEu:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --num-threads=4 --output /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/dex/debug /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/classes/debug /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/dependency-cache/debug /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/acra-4.3.0-b1a053ff2be3ad0658e7414c9efb8db525d279e1.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/android-async-http-1.4.4-5a7d308e504ef524369d10df7ad6b18d2333a474.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/annotations-12.0-f2c0a1768643eb7fbcddd7f90bd7fdcf4b535025.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-0f154ba1813ed5f2748c80e42224f29d69f31319.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-2ab91006f92af352b41fd4a9cf08b90ebc384663.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-308ca14b92a9fbc70b6a0c8040e145491fe009db.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-30ff1a32817de610075def282e38c869b04a28dc.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-367f4c8350acbcca39b062f9298b4706d303d64e.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-51e92b8a83db801d712dc0a6700756d222ff3d7c.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-954a78d07e1cba7e60b32fc998618db2b73536e5.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-95ba17748132eea2f6b9fe72f64146a711039a2e.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-98f64520cfb53411ed06a971922b9136a7f886db.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-9ad84293ee46c4d1204f00c5a365ece1f451993d.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-9f06efdb2c5340fb2b4c90881246b07488331f61.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-ac9167c19813fd3034915e682cabd31010f5aea8.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-accd233c53f9d41450f400d9af655aba4e024959.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-b366d899959a2cce72d0209dc8cd82ba6acfc51c.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-bd9b360242c9c5d28979cc9db28b5b6d13d5adf9.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-beb603821493ae18d2e211c4ebc15c24d939288f.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-c3e39f4f328039d2cfa6a50202a0dd905bb28947.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-c432d4669d088a374e8c2f646918795e6afd502e.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-e40aab9c8425cb5480d94955ff39b94eba0673fe.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-e5cf02936df1867bef02bb7eba9cf7e782f8f580.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-e6d28e65693575cc752648484d16f78af3e72109.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-ed9e48e9155c614bf3fa9c35be086555a10775ac.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/commons-io-1.3.2-5123b7dd8aac03253c765cf8fdc5e64bd1d87e62.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/commons-lang3-3.3.2-2c464519455a1eb9cdda46245fc20ffc1add2f52.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/disklrucache-2.0.2-a9c89aae05bf7016b5926b3c62ece24b06cfd098.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/internal_impl-20.0.0-b6e3d4dce38e3b09e28016e8db8e4ae1bb763024.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/lib-core-3.0.0-70b1696546add9933c9d0ae0be680ebb68143b3e.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/library-2.4.0-8bb96134963e47cabbae008ca69e322b1f133527.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/okhttp-1.6.0-0cf0746018b0646a0e162fd0629520e2fbb998d1.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/okhttp-urlconnection-1.6.0-d1ddb162604ccb14c556bd8d52c46ce1abd8f372.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/support-annotations-21.0.0-rc1-9da56907a54bc62b80b021d0066dc3e5625c73ba.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/universal-image-loader-1.9.1-c662c9896a82f0f3822fee3cb4d5ab8000983974.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/nhaarman/listviewanimations/BaseAdapterDecorator;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
Information:BUILD FAILED
Information:Total time: 24.587 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
I have tried both the 3.0 release of the library and 2.6.0 both maven and .jar and still the same error. Also tried cleaning and rebuilding the project.
Anyone got any suggestions on what might be wrong and how to fix it?
My build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
maven {
name 'maven.aviary.com'
url uri("http://maven.aviary.com/repo/release")
}
}
android {
compileSdkVersion 20
buildToolsVersion '20'
defaultConfig {
minSdkVersion 14
targetSdkVersion 20
}
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.android.support:support-v4:20.+'
compile 'com.google.android.gms:play-services:4.4.52'
compile 'ch.acra:acra:4.3.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.1'
compile 'com.loopj.android:android-async-http:1.4.4'
compile 'com.github.johnkil.android-appmsg:appmsg:1.2.0'
compile 'com.aviary.android.feather.sdk:aviary-sdk:3.4.3.351'
compile 'com.nhaarman.listviewanimations:lib-core:3.0.+'
}
UPDATE - SOLVED
Thanks! I used jarjar together with this article to solve the problem.
I appears that the Aviary SDK includes parts listviewanimations.
I recommend you file a bug with Aviary.
Until they fix it, you can use jarjar to move the package com.nhaarman. to a different package.
References:
https://code.google.com/p/jarjar/
https://github.com/vRallev/jarjar-gradle
https://gist.github.com/mcholick/7177513

Building stORM getting dex error upon building with Gradle and Android Studio

stORM https://code.google.com/p/storm-gen/
I have the following in build.gradle
...
dependencies {
compile 'com.android.support:support-v13:+'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.googlecode.libphonenumber:libphonenumber:6.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'log4j:log4j:1.2.16'
compile 'org.slf4j:slf4j-log4j12:1.6.1'
}
android.applicationVariants.all { variant ->
def aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}")
variant.javaCompile.options.compilerArgs += [
"-processor", "com.turbomanage.storm.apt.MainProcessor",
'-AandroidManifestFile=' + variant.processResources.manifestFile,
'-s', aptOutput
]
variant.javaCompile.source = variant.javaCompile.source.filter { p ->
return !p.getPath().startsWith(aptOutput.getPath())
}
variant.javaCompile.doFirst {
aptOutput.mkdirs()
}
}
...
Dropped in libs:
storm-api-0.97.jar
storm-apt-0.97.jar
And upon building with gradle assembleRelease, I get:
:app:dexRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexRelease'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/xyz/android/sdk/build-tools/19.0.1/dx --dex --output
/xyz/code/studio/Myapp/app/build/dex/release
/xyz/code/studio/Myapp/app/build/classes/release
/xyz/code/studio/Myapp/app/build/dependency-cache/release
/xyz/code/studio/Myapp/app/build/pre-dexed/release/libphonenumber-6.0-abc2e51ec6ac0cb8f28ec86ee41a37511055f6ea.jar
/xyz/code/studio/Myapp/app/build/pre-dexed/release/library-2.4.0-31f82b62b24973486e6bf5acdc255648bd6a567a.jar
/xyz/code/studio/Myapp/app/build/pre-dexed/release/log4j-1.2.16-51a933677ad733ef5cca3cb304434fddd96c08ca.jar
/xyz/code/studio/Myapp/app/build/pre-dexed/release/slf4j-api-1.6.1-a040969be47961e95d820688122f6e64c1ac6025.jar
/xyz/code/studio/Myapp/app/build/pre-dexed/release/slf4j-log4j12-1.6.1-8c58ce04b54255044a79c495ab437e1d1837ca00.jar
/xyz/code/studio/Myapp/app/build/pre-dexed/release/storm-api-0.97-5a13884740c461b336ce512036f4706f19544b0b.jar
/xyz/code/studio/Myapp/app/build/pre-dexed/release/storm-apt-0.97-59dde234977ec5d0b6dadf5e7497cf4d6ccb1649.jar
/xyz/code/studio/Myapp/app/build/pre-dexed/release/support-v13-19.1.0-dd8f989f7c1c7adbefa06c594c0cfc6cb6c75387.jar
/xyz/code/studio/Myapp/app/build/pre-dexed/release/support-v4-19.1.0-155f54881a6e6cf88c81786a2d33043cfc538af3.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/example/storm/BuildConfig;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
The command gradle -q dependencies, shows only
------------------------------------------------------------
Root project
------------------------------------------------------------
No configurations
Im not sure what the problem is, anyone?
It complains that both jars brought BuildConfig class (because of the way the two jars are build right now, which will change in the future).
You don't need the API jar, only the APT one (which contains the API classes, actually). This will remove your dex problem.
Another recommendation is to use android-apt, it'll make your life simpler!

App with Google Maps doesn't build in Android Studio

I'm trying to build an app with Google Maps but whenever I try to run it there's an error message. I've added the following code to my build.gradle:
dependencies {
compile 'com.google.android.gms:play-services:4.2.42'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
And here's the error message:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\Fredrik\AppData\Local\Android\android-studio\sdk\build-tools\19.0.3\dx.bat --dex --output
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\dex\debug
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\classes\debug
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\dependency-cache\debug
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\pre-dexed\debug\android-support-v4-0245b39e700edf6a0cb399c720bb8d324f78e6d1.jar
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\pre-dexed\debug\classes-05dd9eee723585a17563ec87ce727a6f7bafa3c6.jar
C:\Users\Fredrik\AndroidStudioProjects\Skollunch\app\build\pre-dexed\debug\support-v4-19.0.1-b477505a5fac609297d4a580b1fdd1110916d42b.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
When I delete the code in build.gradle it runs fine, but then Maps won't work of course ;). This isn't just the case with Play Services but it does the same thing when I try to add the Support Library.
Does anyone know something that could help me solve the problem?
When using Gradle, don't include android-support-v4 by including the jar file directly; if you do it this way, the build system isn't able to disambiguate multiple copies of the support library it may encounter through direct or transitive dependencies, and you get exactly this error. Instead, remove the jar from your libs directory and include it by supplying its Maven coordinate in the dependencies block of your build file:
dependencies {
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.android.support:support-v4:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}

Categories

Resources