android studio . Error:Execution failed for task ':app:dexDebug' - android

This project in github
https://github.com/RoyWallace/Instagram
It's a android studio project,I run this project meet difficult.It can't run in mobliephone.
this is bulid.gradle(Project :Instagram-master)
// 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.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
build.gradle(Module:app) is this
apply plugin: 'android'
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "etong.instagram"
minSdkVersion 9
targetSdkVersion 19
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.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:support-v4:21.0.3'
}
run with error
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
d:\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\dell\Desktop\mobliegamelive\somecode\Instagram-master\app\build\intermediates\dex\debug --input-list=C:\Users\dell\Desktop\mobliegamelive\somecode\Instagram-master\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/widget/DrawerLayout;
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)
why this happen?
how can i solve it?
Any help will be appreciated

You have problem with support−v۴ library !
see these links maybe help you :
Android Dex: UNEXPECTED TOP-LEVEL EXCEPTION: Already added
Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION:
UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException

Related

Multiple dex files in Android Studio?

HI i found this error and for last two days i am playing with error but did not run the project. please any one help me. i delete the android support v4.jar from main project not delete from libraries project because they have their own dependencies and also delete the anotation jar. annotation jar, android support v4, and appcompact v4 is using in External Libraries project. but still i found this issue. this is my jar list
android-support-v7-recyclerview.jar
AndroidAnimations.jar
AndroidEasingFunctions-1.0.0.jar
google-http-client-1.16.0-rc.jar
google-play-services.jar
gson-2.1.jar
And this is my gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 21
buildToolsVersion '21.0.1'
defaultConfig {
applicationId "com.iptikarpromotion"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile files('libs/android-support-v7-recyclerview.jar')
compile files('libs/AndroidAnimations.jar')
compile files('libs/AndroidEasingFunctions-1.0.0.jar')
compile files('libs/google-http-client-1.16.0-rc.jar')
compile files('libs/google-play-services.jar')
compile files('libs/gson-2.1.jar')
compile project(':libraries:ImageSliderLibrary')
compile project(':libraries:GalleryViewLibrary')
}
please see this belopw error
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
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)
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_79\bin\java.exe'' finished with non-zero exit value 2
The class android/support/annotation/AnimRes is included twice in your project, maybe in two different libraries. You need to find it out what is and exclude one of them.

com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;

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.

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

Android Studio & Gradle: Multiple dex files

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

Build Tools 21.1.2 – UNEXPECTED TOP-LEVEL EXCEPTION

I'm suddenly running into this issue when building/running my project.
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/aidanfollestad/Documents/android-sdk/build-tools/21.1.2/dx --dex --no-optimize --output /Users/aidanfollestad/Android Projects/Impression/app/build/intermediates/dex/debug --input-list=/Users/aidanfollestad/Android Projects/Impression/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: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)
My Gradle file contains this:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.14.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'versionPlugin'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.afollestad.impression"
minSdkVersion 16
targetSdkVersion 21
versionCode 19
versionName "0.7.0"
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.koushikdutta.ion:ion:2.0.+'
compile 'com.github.chrisbanes.photoview:library:1.2.+'
compile 'com.afollestad:material-dialogs:0.4.5'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.api-client:google-api-client-gson:1.18.0-rc'
compile 'com.google.apis:google-api-services-drive:v2-rev152-1.19.0'
compile('com.crashlytics.sdk.android:crashlytics:2.1.0#aar') {
transitive = true;
}
}
versionPlugin{
buildTypesMatcher = 'release'
supportBuildNumber = false
fileNameFormat = '$appPkg-v$versionName-$versionCode'
}
My material-dialogs library references only AppCompat-v7, the same version this Gradle file is referencing. I don't have any JARs in my libs folder that I'm referencing. I have no idea what libraries are interfering with each other (other than the possibility of Play Services and AppCompat?). Any ideas or solutions?
I noticed Ion references v4 of the support library (https://github.com/koush/ion/blob/master/ion/build.gradle#L17), maybe that could be interfering with AppCompat?
Try to enable multidex build.gradle :
android {
defaultConfig {
...
multiDexEnabled = true
}
}
Ref : Unable to execute dex: method ID not in [0, 0xffff]: 65536
You may hitted the 65k methods limit. Instead of using multiDex, try 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.
This exception shows that your project have reached to maximum number of methods 65536. you just do the below work.It worked for me
Step 1:
inside build.gradle
defaultConfig {
multiDexEnabled = true
}
Step 2:
inside manifest application tag
android:name="android.support.multidex.MultiDexApplication"
or
Step 3: if You use Class which extends Application then do:
public class MyApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Step 4:
inside build.gradle
android{
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}

Categories

Resources