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'
Related
Hello I am working on a project for which I am using Android Studio. I have setup everything but when I run my project then I get below errors. I could not resolve it for last 2 days. What could be the problem in my project that causing this error
Please help if anyone know about this.
app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "in.xyz"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
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:22.0.+'
//compile files('libs/android-support-v4.jar')
compile 'com.android.support:support-v4:22.0.+'
compile 'com.android.support:support-annotations:20.0.0'
}
library build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
//compile files('libs/android-support-v4.jar')
compile 'com.android.support:support-v4:22.0.+'
compile 'com.android.support:support-annotations:20.0.0'
}
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
...
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'.
settings.gradle
include ':app'
include ':multiStateToggleButton'
Your problem i believe is that wherever you are linking the Library to your Main Project you have the same dependencies between the two for your support library and annotations.
If you have the library project as a dependency in your application you will only need the dependency to be placed in the library dependencies closure.
The issue is that you have two dex files because there are two Files with the same name because the overlap in files with your dependencies.
First copy your module to your libs/ folder of your main project then,
create your settings.gradle file in the root of the main project:
include 'app_name', 'library_name'
project(':LibraryNameGoesHere').projectDir = new File('libs/LibraryNameGoesHere')
For your library's build.gradle
dependencies {
compile files('libs/android-support-v4.jar')
compile 'com.android.support:support-v4:22.0.+'
compile 'com.android.support:support-annotations:20.0.0'
}
Then for your main project build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.+'
compile project(":libs:LibraryNameGoesHere")
}
Since facebook sdk configed for using Android 2.3.3, it requires annotaion lib.
My app configed for using Anndoid > 4.x.x, which is contains Annotation, the conflict was emarged.
I have changed, in the facebbok mainfest, to work with Android > 4.x.x and it solved the problem.
if you migrate the project from eclipse to studio , and then your project need a new module, you add the build.gradle which in the module, add the dependencies like this,
compile 'com.android.support:support-annotations:24.1.1'
compile 'com.android.support:support-v4:24.1.1'
//recyclerview
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
you might be see this stupid problem because the old project has include the jar file like android-support-v4.jar
this shit is overlay the compile(thing) so you must remove the *.jar file,
this shit takes my hole afternoon, so good luck ,my english is pool,
fogiven me please
For what it's worth I was getting this error after using Android Studio to import a project from Eclipse. In the /app/build.gradle file I had two entries in the dependencies section, it looked like this
dependencies {
compile files('libs/android-support-v13.jar')
compile files('libs/android-support-v4.jar')
}
I removed the reference to v4 like below
dependencies {
compile files('libs/android-support-v13.jar')
}
I cleaned the project and was able to build my APK. I don't know if this was the correct way to fix it but it worked for me.
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
I want to use Android L compat libs. after adding the relevant code to gradle, I get the error:
Error Code:
2
Output:
objc[36290]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
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)
I saw questions about it this here and here, and tried out the solution from this blog post, and I still get an error, where in the case of the blog post, I get:
Error Code:
2 Output:
objc[36323]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Library dex files are not supported in multi-dex mode
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:322)
at com.android.dx.command.dexer.Main.run(Main.java:228)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
These are my android gradle settings:
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.my.package"
minSdkVersion 9
targetSdkVersion 21
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
These are my dependencies:
dependencies {
compile project(':libraries:ecoGallery')
compile project(':libraries:facebookSDK')
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.mixpanel.android:mixpanel-android:4.3.1#aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.nineoldandroids:library:2.4.0'
compile 'oauth.signpost:signpost-commonshttp4:1.2.1.2'
compile 'oauth.signpost:signpost-core:1.2.1.2'
compile 'com.uservoice:uservoice-android-sdk:+#aar'
compile 'com.newrelic.agent.android:android-agent:4.87.0'
compile 'com.google.guava:guava:18.0'
compile files('libs/android-support-multidex.jar')
}
Does anyone have any ideas for what I might be doing wrong?
Gradle plugin v0.14.0 for Android adds full multidex support.
Remove all the build.gradle changes you made (for multidex), and simply add the following:
android {
defaultConfig {
...
multiDexEnabled = true
}
}
Trying adding the following code to your build.gradle, worked for me.
android{
...
dexOptions {
preDexLibraries = false
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
...
}
instead of including the entire google library,
use only the ones you require.
for ex. use:
compile 'com.google.android.gms:play-services-maps:7.8.0'
compile 'com.google.android.gms:play-services-location:7.8.0'
instead of
compile 'com.google.android.gms:play-services:7.8.0'
Try to disabled "Instant run":
In android studio:
Menu File -> Settings
In Build, Execution, Deployment -> Instant run
UNCHECK Enabled Instant Run to hot swap code/resource changes on deploy (default enabled)
None of the answers they gave you were exhaustive. The problem lies in the Multidex. You must add the library in the app gradle :
implementation 'com.android.support:multidex:1.0.3'
After, add in the defaultConfig of the app gradle :
multiDexEnabled true
Your Application must be of the Multidex type.. You must write it in the manifest :
android:name=".MyApplication"
MyApplication must be either the Multidex class, or it must extend it.
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
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