Android studio does not let me compile project - android

I have googled to find a solution, but I have tried all the ways and any of them works. First my project works with any problem, later I added some changes and this happened. When I delete all the changes, the problem has not dissapeared. When I try to complie the project, gradle console shows:
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/user/Android/Sdk/build-tools/22.0.0/dx --dex --no-optimize --output /home/projectpath/app/build/intermediates/dex/debug --input-list=/home/projectpath/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)
This is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "application.com.name"
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:+'
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:22.0.+'
compile 'com.jakewharton:butterknife:5.1.2'
compile 'com.jakewharton.timber:timber:2.5.0'
compile 'fr.tvbarthel.lib.blurdialogfragment:lib:1.1.0#aar'
compile 'com.github.chenupt.android:multiplemodel:1.1.0#aar'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.google.guava:guava:18.0'
compile 'com.jpardogo.materialtabstrip:library:1.0.8'
compile 'com.getbase:floatingactionbutton:1.7.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
}
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(dir: 'libs', include: 'ParseCrashReporting-*.jar')
}

This kind of issue UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException:
happens when you are using the same library with a different version.
The problem is here:
You are using
compile 'com.parse.bolts:bolts-android:1.+'
Currently the version is 1.2
The facebook (3.21.1) library is using the 1.1.2 version
Also you are using
compile 'com.android.support:appcompat-v7:+'
It means the release 22.
The facebook library uses the 20-21.

Related

Android Studio: Error:Execution failed for task ':app:dexDebug' when build project

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 ':xink:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\user\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output E:\xink App\Xink\xink\build\intermediates\dex\debug --input-list=E:\xink App\Xink\xink\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: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: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)
The app build.gradle is this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.vog.xink"
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile project(':library')
compile project(':facebook')
compile project(':swipecard')
compile files('libs/android-query-full.0.26.7.jar')
compile files('libs/httpmime-4.1.1.jar')
compile files('libs/google-api-client-1.10.3-beta.jar')
compile files('libs/google-http-client-1.10.3-beta.jar')
compile files('libs/google-api-client-android2-1.10.3-beta.jar')
compile files('libs/google-http-client-android2-1.10.3-beta.jar')
compile files('libs/google-oauth-client-1.10.1-betar.jar')
compile files('libs/jackson-core-asl-1.9.4.jar')
compile files('libs/jsr305-1.3.9.jar')
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.etsy.android.grid:library:1.0.5'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.jpardogo.materialtabstrip:library:1.0.6'
compile 'com.crittercism:crittercism-android-agent:+'
compile 'org.jsoup:jsoup:1.7.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.code.gson:gson:2.3'
compile 'com.androidmapsextensions:android-maps-extensions:2.2.0'
compile 'com.google.guava:guava:18.0'
}
You are probably including the same library more than once. Try to include just one google-api-client and just one google-http-client.

'UNEXPECTED TOP-LEVEL EXCEPTION' multiple dex files define...in Android Studio with Jasypt

So i've been getting this unexpected top level exception error after adding the jasypt libraries to my project. I've tried a lot of the other fixes suggested in other similar questions to no avail
Here's my gradle build message:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/jasypt/spring/properties/EncryptablePreferencesPlaceholderConfigurer;
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\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 2
and here's my build.gradle(app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.verve.eventfloc"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
compile files('libs/jasypt-spring31-1.9.2.jar')
compile files('libs/jasypt-springsecurity2-1.9.2.jar')
compile files('libs/jasypt-1.9.2-sources.jar')
compile files('libs/jasypt-spring2-1.9.2-sources.jar')
compile files('libs/jasypt-1.9.2.jar')
compile files('libs/jasypt-hibernate3-1.9.2-javadoc.jar')
compile files('libs/jasypt-spring2-1.9.2.jar')
compile files('libs/jasypt-hibernate3-1.9.2.jar')
compile files('libs/jasypt-spring3-1.9.2-sources.jar')
compile files('libs/jasypt-springsecurity2-1.9.2-sources.jar')
compile files('libs/jasypt-hibernate4-1.9.2-sources.jar')
compile files('libs/jasypt-hibernate4-1.9.2.jar')
compile files('libs/jasypt-springsecurity2-1.9.2-javadoc.jar')
compile files('libs/jasypt-acegisecurity-1.9.2-javadoc.jar')
compile files('libs/jasypt-hibernate3-1.9.2-sources.jar')
compile files('libs/icu4j-3.4.4.jar')
compile files('libs/jasypt-1.9.2-javadoc.jar')
compile files('libs/jasypt-1.9.2-lite.jar')
compile files('libs/jasypt-spring31-1.9.2-javadoc.jar')
compile files('libs/jasypt-acegisecurity-1.9.2-sources.jar')
compile files('libs/jasypt-springsecurity3-1.9.2-javadoc.jar')
compile files('libs/jasypt-spring3-1.9.2-javadoc.jar')
compile files('libs/jasypt-spring31-1.9.2-sources.jar')
compile files('libs/jasypt-spring3-1.9.2.jar')
compile files('libs/jasypt-springsecurity3-1.9.2-sources.jar')
compile files('libs/jasypt-acegisecurity-1.9.2.jar')
compile files('libs/jasypt-springsecurity3-1.9.2.jar')
compile files('libs/jasypt-wicket13-1.9.2.jar')
compile files('libs/jasypt-spring2-1.9.2-javadoc.jar')
compile files('libs/jasypt-hibernate4-1.9.2-javadoc.jar')
compile files('libs/jasypt-wicket13-1.9.2-sources.jar')
compile files('libs/jasypt-wicket13-1.9.2-javadoc.jar')
compile files('libs/jasypt-wicket15-1.9.2.jar')
compile files('libs/jasypt-wicket15-1.9.2-javadoc.jar')
compile files('libs/jasypt-wicket15-1.9.2-sources.jar')
}
I tried adding an exclusion in the build.gradle as per this question but I then get prompts to implement the getSupportFragmentManager() method in my class.
When I alt-enter again for the suggestion, it tells me to import fragment manager and then to return android.support.v4.app.FragmentManager in getSupportFragmentManager(). It also seems to mess up Context whenever i've used ".this"
Any help will be greatly appreciated. Thanks

unexpected top level exception in android studio

I am trying to build my app but when i try to make it a signed apk it says this:
Error:Execution failed for task ':app:dexRelease'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\rik\AppData\Local\Android\sdk\build-tools\21.1.0\dx.bat --dex --output C:\Users\rik\Desktop\CCApp\app\build\intermediates\dex\release --input-list=C:\Users\rik\Desktop\CCApp\app\build\intermediates\tmp\dex\release\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: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)
its really anoying me and i need to build the app very soon,
hope someone can help me
EDIT added build.gradle
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "it.experium.ccapp"
minSdkVersion 9
targetSdkVersion 21
versionCode 3
versionName "3.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'ParseCrashReporting-*.jar')
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
}
EDIT file tree of the libs folder
parse-1.8.2-javadoc (Folder)
ParseCrashReporting-1.8.2-javadoc (Folder)
bolts-android-1.1.4 (Jar)
bolts-android-1.1.4 (Properties File)
bolts-android-1.1.4-javadoc (Jar)
Parse-1.8.2 (Jar)
Parse-1.8.2 (Properties file)
Rooster (In english Schedule, i have this because i request json's with this file. Jar)
third_party_licenses (TXT)
It seems like you are using here multiple jar files for same reference it may take some difference version of it..
So, it's better to remove below lines
compile fileTree(dir: 'libs', include: 'ParseCrashReporting-*.jar')
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
Because 1st and 3rd line of this code included in single line so, no need to put those extra lines..
compile fileTree(dir: 'libs', include: ['*.jar'])
You are here putting external jar bolts-android-1.1.4 (Jar) as a reference from lib folder so, no need to add this gradle dependency..
compile 'com.parse.bolts:bolts-android:1.+'
So, after removing those 3 line sync project you will get your project running without any issue..
Let us know if anything needed...

UNEXPECTED TOP-LEVEL EXCEPTION while adding google play services

I am developing an android app where I am integrating Google Plus Login. For this, I've added google play services library to my project. When I run my app, it gives me following error :
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)
This is my build.gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.genes_x.googleplus"
minSdkVersion 9
targetSdkVersion 21
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.0'
compile 'com.google.android.gms:play-services:7.0.0'
//compile 'com.google.android.gms:play-services-plus:7.0.0'
//compile 'com.google.android.gms:play-services-identity:7.0.0'
compile files('E:/google plus/GooglePlus/libs/google-play-services.jar')
}
I've been gone through many questions on stackoverflow but didn't get solution. Anything wrong in my build.gradle file..??
The error is pretty obvious. You are compiling google play services twice. Should be:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
//compile 'com.google.android.gms:play-services-plus:7.0.0'
//compile 'com.google.android.gms:play-services-identity:7.0.0'
//compile files('E:/google plus/GooglePlus/libs/google-play-services.jar')
}

Android Studio error, multiple dex files

I am unable to build my project, it is returning me one error. There are no errors in the files themselves, only upon a build.
This is the following error:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\Jay\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\Jay\Desktop\UploadToServer\app\build\intermediates\dex\debug --input-list=C:\Users\Jay\Desktop\UploadToServer\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)
I have read on a few other post that it could be multiples of the same jar files in the libs folder but currently my folder is empty, I am not to sure what the issue is, I would appreciate if someone could help.
Here is my module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.jay.uploadtoserver"
minSdkVersion 16
targetSdkVersion 21
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:21.0.3'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.android:support-v4:r6'
compile 'org.apache.httpcomponents:httpmime:4.2.3'
}
Some of your jar files does not compile. You should go into your build.gradle file in your project, and look in your dependencies, if your just import some jar files, you could try to remove them, and add one at a time, to see which one of them makes the error.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.android:support-v4:18.0.+'
}
Remove compile 'com.google.android:support-v4:r6'. AppCompat already has this library

Categories

Resources