user3563459
user3563459

Reputation: 717

Unable to run project on android studio

I am trying to run project on Android device as well as on emulator. but unfortunately I am getting two errors.

Error 1:

Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

Error 2:

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 '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

Upvotes: 1

Views: 146

Answers (2)

Geralt_Encore
Geralt_Encore

Reputation: 3771

In your build.gradle:

android {
compileSdkVersion 22
buildToolsVersion "23.0.0"

     defaultConfig {
         minSdkVersion 14 //lower than 14 doesn't support multidex
         targetSdkVersion 22

         // Enabling multidex support.
         multiDexEnabled true
     }
}

dependencies {
    compile 'com.android.support:multidex:1.0.1'
}

Then you need to extend your application class from MultiDexApplication or include this snippet into it:

public class YouApplication extends Application {

    @Override
    protected void attachBaseContext(Context base) {
         super.attachBaseContext(base);
         MultiDex.install(this);
    }

}

Here is the official guide.

Upvotes: 0

jdstaerk
jdstaerk

Reputation: 892

I had some problems like your first problem too some time ago. I solved it by using multiDexEnabled true in the defaultConfig. You should try that out!

Upvotes: 1

Related Questions