android build-gradle error :app:dexDebug - android

Here is my build.gradle file (inside the app module):
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.myFirtApp"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories { mavenCentral() }
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'com.google.android.gms:play-services:7.0.0'
}
The error I get:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
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.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.command.Main.main(Main.java:106)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:283)
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_02\bin\java.exe'' finished with non-zero exit value 2
Has anyone else encountered this issue? Any help would be greatly appreciated.

The issue is solved; one of the jar files was beta version and was causing issues after two days of usage; once deleted, the app run properly.

Related

Android studio through Multi Dex error in my project

I tried to run my app in ANdroid Studio but I have this error :
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/loopj/android/http/AsyncHttpClient$1;
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_91\bin\java.exe'' finished with non-zero exit value 2
I don't know where is the problem.
I am not able to modify and run anything as it don't run anymore.
Thank's in advance for you're help.
For example my class mainactivity have one error in :
addOnPageChangeListener
My gradle :
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "info.picse.kids_phone"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:23.3.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.android.support:support-v4:23.3.0'
}
my libs :
enter image description here
On that screenshot you also have jar for gson. Here's the gradle for gson:
//gson 2.2.2
compile 'com.google.code.gson:gson:2.2.2'
Dont forget add the maven
repositories {
mavenCentral()
}

Android Paypal dependency UNEXPECTED TOP-LEVEL EXCEPTION:Execution failed for task dexDebug

I'm developing an Android application and want to integrate Paypal.
When I'm compiling I get the following error:
Information:Gradle tasks [:Pick & Park:assembleDebug]
:Pick & Park:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:Pick & Park:compileDebugNdk UP-TO-DATE
:Pick & Park:compileDebugSources
:Pick & Park:preDexDebug UP-TO-DATE
:Pick & Park:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
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)
Error:Execution failed for task ':Pick & Park:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_60\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 10.726 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
My build gradle dependencies:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.0'
defaultConfig {
applicationId "com.pickandpark.pickandpark"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.code.gson:gson:2.5'
compile 'com.paypal.sdk:paypal-android-sdk:2.12.4'
}
So I definitely know it has something to do with the Paypal dependency. I think I have to exclude some dependency from Paypal, I already tried to exclude Gson from paypal but it doesn't solve the problem.
Thanks in advance!
Lennart
If you just need ads, identity and gcm then try removing
compile 'com.google.android.gms:play-services:8.3.0'
Error most probably due to the 65k limit. Also enable MultiDex.

Multiple dex files define android/support/annotation/AnimRes

When I`m tring to run my app, I receive the following error:
app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:preDexDebug
:app:dexDebug
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'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.8.0_05\bin\java.exe'' finished with non-zero exit value 2
The content of the gradle script is:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
minSdkVersion 10
targetSdkVersion 22
versionCode 289
versionName "2.2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles 'proguard-android.txt', 'proguard-rules.txt'
}
debug {
debuggable true
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile('com.facebook.android:facebook-android-sdk:3.23.1') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile('com.crashlytics.sdk.android:crashlytics:2.3.1#aar') {
transitive = true;
}
compile project(':UtilsLibrary')
compile project(':NumberPickerLibrary')
compile project(':drag-sort-listview-lib')
compile project(':GoogleAPI Library')
compile project(':MenuDrawerLibrary')
compile project(':IOLibrary')
compile project(':AR Library')
compile project(':GoogleLicense')
compile project(':android-maps-utils-library')
}
I`m sure that somehow I added twice an of the google libraries.
Thanks.
check the other modules, which are compiled for this module.
The best way to see what is contained as dependencies is to use gradlew.
see here how to generate the dependencie three.
now you have to look with the three where the other google librarie is.

UNEXPECTED TOP LEVEL EXCEPTION in android studio

I was trying to code a simple android app and i get this error message.Please help
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\Users\user\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\user\Desktop\SocialNetworking\app\build\intermediates\dex\debug --input-list=C:\Users\user\Desktop\SocialNetworking\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lbolts/AggregateException;
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)
My gradle build is as follows
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "jason.orchid.com.socialnetworking"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories { mavenCentral() }
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 'com.parse.bolts:bolts-android:1.1.4'
compile 'com.facebook.android:facebook-android-sdk:3.23.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
}
It is because you have included 'com.parse.bolts:bolts-android:x.x' twice in your dependencies. Remove any one of them and the problem will be resolved.

UNEXPECTED TOP-LEVEL EXCEPTION when adding play-services

I have a project where I need to use the Google play service libary. But when I add it to my dependencies i get the following error:
UNEXPECTED TOP-LEVEL EXCEPTION
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Eclipse\adt-bundle-windows-x86_64-20140702\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\Reigstad\Documents\secret-tyrion-android\Tyrion\app\build\intermediates\dex\debug --input-list=C:\Users\Reigstad\Documents\secret-tyrion-android\Tyrion\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:283)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
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)>
My build.gradle looks like this:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'org.immutables:gson:1.1.3'
compile 'org.parceler:parceler:0.2.15'
compile 'com.google.android.gms:play-services:6.5.87'
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.tyrion.tyrion"
minSdkVersion 13
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
}
repositories { mavenCentral()}
I have tried all the solutions that I could find, but none of them seems to work for me. My project works fine, its just when I add the libary it wont work.
Hope you guys can help.
You may hitted the 65k methods limit. To use Google Play Services with more granularity, follow this guide, you can use only parts that you want. Probably this will fix your problem

Categories

Resources