1

I'm getting the below error while attempting to build APK. I have read several posts on how to resolve the problem, but as I have not been developing for that long, i'm unsure what I am doing. So, hope someone can help.

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.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 

This is my build.gradle (Module)

apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "com.example.dawnlp.mymap" minSdkVersion 22 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.1.0' compile 'com.google.android.gms:play-services:10.0.1' testCompile 'junit:junit:4.12' } 

and this is my build.gradle project

/ 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:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } 

Would appreciate it if someone could help out, also bare in mind I'm a little inexperienced.

2
  • you have to enable multidex as your methods are more than 65536 or you can simple replace play-services library with what ever is needed like ad etc Commented Feb 28, 2017 at 8:43
  • Enable multidex Commented Feb 28, 2017 at 8:46

3 Answers 3

1

Use it :

android{ defaultConfig { multiDexEnabled true } } 

And use it too

 dependencies { compile 'com.android.support:multidex:1.0.1' } 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Do you mean place defaultConfig { multiDexEnabled true } into dependencies { compile 'com.android.support:multidex:1.0.1' }
Like this dependencies { defaultConfig { multiDexEnabled true } compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.1.0' compile 'com.google.android.gms:play-services:10.0.1' testCompile 'junit:junit:4.12' }
1

You need to enable multidex, add this line to your defaultConfig :

multiDexEnabled true 

And this line to your dependencies :

compile 'com.android.support:multidex:1.0.1' 

Also, as you are running unit tests, you need to create a class that extends the application and install MultiDex :

public class YouApplication extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } } 

2 Comments

Thanks. Where is defaultConfig?
In the build.gradle (Module) file.
0

use this block in your module level gradle : dexOptions { javaMaxHeapSize "4g" }

And in manifest change the application name to .multidex. hope your code will work fine now

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.