Assembly Tools 21.1.2 - UNCERTAIN EXCLUSION OF TOP LEVEL

I suddenly have a problem when creating / starting 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 the following:

 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' } 

In my library of dialog materials only AppCompat-v7 is referenced, the same version referenced by this Gradle file. I do not have a JAR in my libs folder to which I refer. I have no idea which libraries interfere with each other (besides the Play Services and AppCompat features?). Any ideas or solutions?

I noticed links from the Ion v4 support library ( https://github.com/koush/ion/blob/master/ion/build.gradle#L17 ), maybe this can interfere with AppCompat?

+5
source share
3 answers

Try enabling multidex build.gradle:

 android { defaultConfig { ... multiDexEnabled = true } } 

Ref: Unable to execute method identifier dex: not in [0, 0xffff]: 65536

+12
source

You can use the limit of 65k methods. Instead of using multiDex, try using Google Play Services with more granularity. Follow this guide , you can use only those parts that you want. This will probably fix your problem.

+11
source

This exception indicates that your project has reached a maximum of 65536 methods. You are just doing the work below. He 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 are using a class that extends the application, follow these steps:

  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" } } 
+2
source

Source: https://habr.com/ru/post/1209191/


All Articles