Error Code:2 Unexpected Top-level Exception - android

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.

Related

Android Aws Library - UNEXPECTED TOP-LEVEL EXCEPTION

when i try to use aws-android-sdk-s3 library i recive this error
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
xxxxxxxxxxxxxxxl\Android\sdk\build-tools\21.1.2\dx.bat --dex --output xxxxxxxxxxxxxxxxxxx\app\build\intermediates\dex\debug --input-list=xxxxxxxxxxxxxxxxxxxxxxxdex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: Cannot merge new index 65727 into a non-jumbo instruction!
at com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:109)
at com.android.dx.merge.InstructionTransformer.access$800(InstructionTransformer.java:26)
at com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:72)
at com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)
at com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)
at com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:49)
at com.android.dx.merge.DexMerger.transformCode(DexMerger.java:842)
at com.android.dx.merge.DexMerger.transformMethods(DexMerger.java:813)
at com.android.dx.merge.DexMerger.transformClassData(DexMerger.java:785)
at com.android.dx.merge.DexMerger.transformClassDef(DexMerger.java:682)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:542)
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)
this is my gradle
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':extendedCalendarView')
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
compile 'com.github.nirhart:parallaxscroll:1.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.amazonaws:aws-android-sdk-core:2.2.3'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.3'
it work all fine till i add the last line and i dont know what can be..searching here on stackoverflow i saw there can be a duplicate declaration of the library support-v4 but i dotn see any :( what can be? :(
How to enable multidexing with the new Android Multidex support library . here you can find the best answer for your question.by default android studio support multidex for exceeds 65k+ methods.jsut simply follow the lines

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.

CardView and recycleView duplicate error

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.

Error while including library in android studio 1.0.2

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.

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

I'm using Android Studio for the first time and I got the following error after importing the project (previously it was an eclipse project where I had issues too.)
Here is the information given:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/crash-id/Development/SDK/adt-bundle-linux-x86_64-20140702/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /home/crash-id/AndroidstudioProjects/LocalSin/app/build/intermediates/dex/debug --input-list=/home/crash-id/AndroidstudioProjects/LocalSin/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/ads/AdRequest$ErrorCode;
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)
:app:dexDebug
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: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:
/home/crash-id/Development/SDK/adt-bundle-linux-x86_64-20140702/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /home/crash-id/AndroidstudioProjects/LocalSin/app/build/intermediates/dex/debug --input-list=/home/crash-id/AndroidstudioProjects/LocalSin/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/ads/AdRequest$ErrorCode;
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)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
The app build.gradle is this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.myapp.test"
minSdkVersion 11
targetSdkVersion 14
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:+'
compile files('libs/google-play-services.jar')
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.3.4.jar')
}
And the project built.gradle is this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Do you have any idea what the problem could be and how can it be solved? A good explanation for the problem would be useful too as I am new to Android Studio. Thanks in advance :)
compile 'com.google.android.gms:play-services:+'
compile files('libs/google-play-services.jar')
I think you should remove 1 of those lines.
cd android/ && ./gradlew clean && cd .. && react-native run-android
I had the Android Studio Error:Execution failed for task ':app:dexDebug' that i solve it by setting multiDexEnabled to true
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
Too many library were used in my project so i exceed the 65K methods dex limit imposed by Android for more information see : http://developer.android.com/tools/building/multidex.html
This happens because you are duplicating the library dependency inside of app build.gradle in android studio.
Android Studio automatically adds the dependencies for all the files in the libs folder by using
compile fileTree(dir: 'libs', include: ['*.jar'])
or in your specific case the dependency is added using
compile files('libs/google-play-services.jar')
^ Now when you try to add the dependency again by using
compile 'com.google.android.gms:play-services:+'
you get the error.
SOLUTION
Remove all duplicate dependencies added inside the "app build.gradle" and you should be good to go.In your case remove
compile 'com.google.android.gms:play-services:+'
avoid to include whole gms library:
compile 'com.google.android.gms:play-services:+'
Instead, just use required components in this way:
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
Ensure that the Package names are not duplicated across the projects being compiled
In #Drivers' answer, it is pointed out that in a given project, there should not be multiple dependencies that have the same namespace. In the case above, the Google Play Services library had been included twice, and thus caused a package name conflict.
The same can also happen across multiple modules (apps, libraries etc.) in the same project. So, ensure that for each AndroidManifest.xml file, the package name is unique across all modules:-
AndroidManifest.xml:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="this.must.be.unique.across.modules">
I had the below code on gradle file and same error.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'
}
dependencies {
compile 'com.android.support:design:23.+'
}
dependencies {
compile 'com.android.support:design:23.+'
}
dependencies {
compile 'com.android.support:design:23.+'
}
Removed those last 3 dependencies and now its working!
delete all files in c:\users\<username>\.gradle\caches\transforms-2\files-2.1\
Enjoy the command flutter run

Categories

Resources