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.
Related
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
}
Hi Im trying to use cardview and recycle view in my android studio project. When i put cardview in to my dependencies it works fine. However, when i add the recycle view in to dependencies an error comes up.
can someone tells me how to solve this issue?
my dependencies:
dependencies {
compile files('libs/Parse-1.5.1.jar')
compile files('libs/achartengine-1.1.0.jar')
compile files('libs/android-support-v13.jar')
compile files('libs/picasso-2.3.2.jar')
compile 'com.android.support:cardview-v7:21.0.+'
}
the error code:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/adt-bundle-mac-x86_64-20140702/sdk/build-tools/21.1.1/dx --dex --no-optimize --output /Users/jonathan34c/AndroidstudioProjects/Cue_business1/app/build/intermediates/dex/debug --input-list=/Users/jonathan34c/AndroidstudioProjects/Cue_business1/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: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)
Delete your build folder and then rebuild it. And add dependencies in your app gradle as
dependencies {
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
}
Try this might help you.
I am a new Android Developer and build files always scare me. :D
I am using some third part libraries in the project
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
}
In addition to this I am also using MPAndroidChart(the only jar in the lib folder) which is only available as a jar file and not a gradle dependency.
MPAndroidChart uses NineOldAndroids as a dependency and I suspect one of my other libraries also uses it and it is causing a build fail.
Any idea how to make both these libraries behave?
I checked the similar questions and found one that was exactly my problem-
Gradle error - Execution failed for task ':app:dexDebug'
But he was including the NineOldAndroids library on his own. So he just removed that line and it was working.
One idea that I had was to strip apart the jar and include them as java files in my project, but that seemed like overkill for this problem. I'm sure there must be an easier way?
This is my entire error
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/ValueAnimator$AnimatorUpdateListener;
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)
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\manu.joseph\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\manu.joseph\AndroidStudioProjects\WriteTrack\app\build\intermediates\dex\debug --input-list=C:\Users\manu.joseph\AndroidStudioProjects\WriteTrack\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/nineoldandroids/animation/ValueAnimator$AnimatorUpdateListener;
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)
Add this to your build.gradle :
configurations {
all*.exclude group: 'com.nineoldandroids'
}
Works fine for me ;)
Remove the following line and try again
compile 'com.android.support:support-v4:21.0.3'
I'm a new android developer and not long before I post this answer, I'm facing the same problem too. Googling and only 2 stackoverflow question showed up. Your question, and the stackoverflow question you provided there.
Somehow, after I remove the unused dependency library via project structures (ctrl+alt+shift+s), in my case, it is
compile 'com.rengwuxian.materialedittext:library:1.8.2'
sync the gradle and then poof! I hope it works for you too.
In the end, I ended up adding the library as an external project which did the trick for me.
Detailed instructions here..
How do I add a library project to Android Studio?
Hope this helps someone..
Im trying to import floating button library in my project enter link description here
Im getting an error while building the following
Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
I have searched on stackoverflow and one of solutions suggested to comment the line
apply from: './gradle-mvn-push.gradle'
then, the project builds successfully but giving an error on execution
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\GUJAR\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\GUJAR\AndroidStudioProjects\MyApplication\app\build\intermediates\dex\debug --input-list=C:\Users\GUJAR\AndroidStudioProjects\MyApplication\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/getbase/floatingactionbutton/AddFloatingActionButton$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: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)
dependancy :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile project(':floatingbutton')
}
help me out...
UNEXPECTED TOP-LEVEL EXCEPTION usually happens when you have more than one versions of the same library included and gradle have conflict because of that.
For example if you have jar of some library in you app's build.gradle and the same library as maven dependency in build.gradle of your library project or vice versa you'll get this error. Take a look on this case.
I am new in android development and when importing project in androidstudio
Error:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
E:\android\adt-bundle-windows-x86_64-20140321\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --
output E:\android\CFPEvents\Gradleprojectcfp-android- user\app\build\intermediates\dex\debug --input-list=E:\android\CFPEvents\Gradleprojectcfp-android-user\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/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
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)
inputList.txt File :
E:\android\CFPEvents\Gradleprojectcfp-android-user\app\build\intermediates\classes\debug
E:\android\CFPEvents\Gradleprojectcfp-android- user\app\build\intermediates\pre-dexed\debug\support-annotations-20.0.0- 22f67c0dddc9c688e0794d450b815b28f58e1d83.jar
E:\android\CFPEvents\Gradleprojectcfp-android-user\app\build\intermediates\pre-dexed\debug\internal_impl-20.0.0-70abc57678073852a9e6f7ebae30976bb22ec41d.jar
E:\android\CFPEvents\Gradleprojectcfp-android-user\app\build\intermediates\pre-dexed\debug\universal-image-loader-1.9.1-b9c11698ebf40b256b359f271d0bd7e3629612d8.jar
E:\android\CFPEvents\Gradleprojectcfp-android-user\app\build\intermediates\pre-dexed\debug\xstream-1.4.7-816d435be49dd5bc1f491c17effc3dddbc49ba4a.jar
E:\android\CFPEvents\Gradleprojectcfp-android-user\app\build\intermediates\pre-dexed\debug\libGoogleAnalyticsServices-e2a7597e511aa28da2b973eefa67e920097e0deb.jar
E:\android\CFPEvents\Gradleprojectcfp-android-user\app\build\intermediates\pre-dexed\debug\google-play-services-ee4019f3cee39571bf6dc0f712c4b22b32b6cae3.jar
E:\android\CFPEvents\Gradleprojectcfp-android-user\app\build\intermediates\pre-dexed\debug\android-support-v4-7ec2c6eefdabe7608a38cfb42d3fa0ec0fa556d2.jar
E:\android\CFPEvents\Gradleprojectcfp-android-user\app\build\intermediates\pre-dexed\debug\classes-99d7a950ad16ef4b71207dd3f54ad9df9c933c00.jar
E:\android\CFPEvents\Gradleprojectcfp-android-user\app\build\intermediates\pre-dexed\debug\classes-6090079305bc6decaac8787edd923af44cc8510d.jar
build.gradle File :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/universal-image-loader-1.9.1.jar')
compile files('libs/xstream-1.4.7.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/google-play-services.jar')
compile 'com.google.android.gms:play-services:6.1.71'
}
Googleplayserices is added in android manifest file
android:minSdkversion="14"
android:targetSDKversion="19"
Please help me
This issue happens if you have multiple instance of same library as dependency in your project. Specific to you is the Google play Services
remove
compile files('libs/google-play-services.jar')
from your build.gradle and also remove the jar from your libs directory because you are including all jars in lib directory to your dependency by writing very first line in dependencies closure.
After doing all sync your project with gradle.