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
Related
Today I migrated to Android Studio 1.1 and started to update the version of some libraries. When I build the project using the gradle button everything seems work properly but when I try to run the application I read in the gradle console output the error message that you can see at the end of the post. For the error message is clear for me that some libraries are using internally some libraries that are common between my dependencies and they have likely different versions. Someone knows how can I discover what are the libraries in conflict and how can I fix that issue (I can not remove any library from the project). Below you can find an abstraction of the build files in my project. Thanks in advance :)
Project's gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
app's (main module) gradle file
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'com.myapp'
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName '1.0.0'
}
buildTypes {
debug {
debuggable true
}
release {
debuggable false
}
}
dexOptions {
preDexLibraries = false
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
compile project(':facebook')
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile 'com.squareup.okhttp:okhttp:2.1.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:1.6.0'
compile 'com.path:android-priority-jobqueue:1.1.2'
compile 'com.google.android.gms:play-services-base:6.5.87' // Analytics, GCM
compile 'com.google.android.gms:play-services-maps:6.5.87'
compile 'com.google.android.gms:play-services-location:6.5.87'
compile 'com.android.support:support-v13:21.0.0'
}
Gradle console output:
Error:Class android.support.v4.util.TimeUtils has already been added to output. Please remove duplicate copies.
1 error; aborting
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/MyMAC/Documents/Development/IDE's/adt-bundle-mac-x86_64-20140702/sdk/build-tools/19.1.0/dx --dex --no-optimize .........
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/util/TimeUtils;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:685)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
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)
1 error; aborting
Information:BUILD FAILED
remove android-support-v4 in libs folder in facebook proj or your app module
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!
i know this question has been answered a many times,i tried all ways bt not working for me at all. I refered a lib in android studio,build the project and am getting the following error:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\manalim\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4.2\dx.bat --dex --output E:\MigrationFromEclTostudio\app\build\libs\app-debug.dex E:\MigrationFromEclTostudio\app\build\classes\debug E:\MigrationFromEclTostudio\app\build\dependency-cache\debug E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\classes-9f889413450cab598adf7f9e7fbc4b615d2af144.jar E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\google-play-services-cbe976cd78aae99b019ba10bdd87d55acb9949b6.jar E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\simple-xml-2.6.1-07b87981e87a36154f3c945922849669a8a391c7.jar E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\support-v4-19.0.1-94b91e1fee2be61286a1fe04c97fca852e863a63.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
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)
below is the build.gradle:
**apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:+'
compile files('libs/google-play-services.jar')
compile files('libs/simple-xml-2.6.1.jar')
}
**
build.gradle for app:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
thats it..help would be really appreciated as am working oj it since a very long time..
Thanks & Regards.
Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode
Try removing com.google.admobsdk-googleplay or similar if you already have it, it seems like another plugin is already including the need libraries.
The solution is to remove this line:
compile files('libs/google-play-services.jar')
and to delete the corresponding jar from the lib folder. This is not necessary any more because of this line:
compile 'com.google.android.gms:play-services:+'
Also note that you should generally not put a + there but rather maintain a fixed version number to ensure your app's stability.
E.g.
compile 'com.google.android.gms:play-services:6.5.87'
I have been trying allot to fix this problem. I cant figure out what to do, i get stuck on the following output error when i want to debug the project.
Execution failed for task ':inspectoratecalculator:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\FlikFlak\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4.2\dx.bat --dex --output
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\dex\debug
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\classes\debug
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\dependency-cache\debug
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\android-support-v4-9fdb020c999e0f186e4aef883e8a4b8676e1e3ac.jar
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\classes-3cbf09a1ad548c6398f541ca3aae99491954a4cd.jar
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\support-v4-19.1.0-ce3af6ab4e02f6c952693d6706242484504a4302.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)
-------------------------------------BUILD.GRADLE-----------------------------------
apply plugin: 'android'
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
Remove the v4 JAR file from your project/module jar directory as #rupps mentioned. Also remove your "excludes" piece from the configuration. Because you're using the the appcompat-v7 dependency, you will automatically pick up the v4 support library via Maven.
This may occur because your have same jar referenced during building of project multiple time , may be that jar is already included some other module or library module.double check and make sure that this condition does not exist.
We have faced this kind of problem earlier.
I'm not sure you have same issue with me, but my issue is I use a JDK 1.8 to compile the code, which not supported by android dx tools.
The fix is change the SDK path from 1.8 to a 1.7 JDK in Project's Module Settings.
Reference this for detail config in Mac:
https://stackoverflow.com/a/24680375/1043032
I'm trying to add libraries from maven, specifically, Crouton library.
I can add it, Sync and use the Crouton object in my project, but when trying to run the app, i get this
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':timetable:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Program Files (x86)\Android\android-studio\sdk\build-tools\19.0.1\dx.bat --dex --output D:\Developer\TimeTable3\timetable\build\pre-dexed\debug\crouton-library-1.8.2-c968ce53b92080dec516373cec51e9993ca5051f.jar C:\Users\Shahar\.gradle\caches\modules-2\files-2.1\de.keyboardsurfer.android.widget\crouton-library\1.8.2\725b0873131748c8c1bf2e1a27465e5bea857ab3\crouton-library-1.8.2.jar
Error Code:
1
Output:
error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: class name (de/keyboardsurfer/android/widget/crouton/Configuration$1) does not match path (release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:520)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:665)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
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)
...while parsing release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class
EDIT: gradle file added
this is my gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 15
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:4.0.30'
compile 'de.keyboardsurfer.android.widget:crouton-library:1.8.2'
compile files('libs/ActiveAndroid.jar')
}
if i use all three without "de.keyboardsurfer.android.widget:crouton-library:1.8.2"
then it all works ok.
Yeah, the build was broken. I didn't notice it locally. But thanks to you it's fixed and deployed to maven central. Clear your cache to get the new build of 1.8.2.
It looks like the crouton library is mispackaged. If you examine its contents:
jar -tf /Users/sbarta/.gradle/caches/modules-2/files-2.1/de.keyboardsurfer.android.widget/crouton-library/1.8.2/725b0873131748c8c1bf2e1a27465e5bea857ab3/crouton-library-1.8.2.jar
META-INF/
META-INF/MANIFEST.MF
release/
release/de/
release/de/keyboardsurfer/
release/de/keyboardsurfer/android/
release/de/keyboardsurfer/android/widget/
release/de/keyboardsurfer/android/widget/crouton/
release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class
release/de/keyboardsurfer/android/widget/crouton/Configuration$Builder.class
release/de/keyboardsurfer/android/widget/crouton/Configuration.class
release/de/keyboardsurfer/android/widget/crouton/Crouton.class
release/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.class
release/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.class
release/de/keyboardsurfer/android/widget/crouton/Manager$1.class
release/de/keyboardsurfer/android/widget/crouton/Manager$Messages.class
release/de/keyboardsurfer/android/widget/crouton/Manager.class
release/de/keyboardsurfer/android/widget/crouton/Style$1.class
release/de/keyboardsurfer/android/widget/crouton/Style$Builder.class
release/de/keyboardsurfer/android/widget/crouton/Style.class
release/de/keyboardsurfer/mobile/
release/de/keyboardsurfer/mobile/app/
release/de/keyboardsurfer/mobile/app/android/
release/de/keyboardsurfer/mobile/app/android/widget/
release/de/keyboardsurfer/mobile/app/android/widget/crouton/
release/de/keyboardsurfer/mobile/app/android/widget/crouton/BuildConfig.class
Everything is inside a release directory, but based on the error message, Configuration$1.class is in the package de.keyboardsurfer.android.widget.crouton (without release). You can contact the library author, or you could disassemble the jar, pull everything inside the release directory one level up, and repackage it.
The packing is wrong for the library on maven repository. So by the time it is corrected by author you can use the this libary as module by downloading and adding it in your project structure .
The path is https://github.com/keyboardsurfer/Crouton
I have informed author Benjamin Weiss on Google plus regarding the same.