4

Good Day, I can't build my project, there was and error like: "The number of method references in a .dex file cannot exceed 64k"

and I have tried to implement MultiDex enabled, but there is another exception...

Message From Gradle Build:

Information:Gradle tasks [:app:assembleDebug]
Error:UNEXPECTED TOP-LEVEL ERROR:
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:  at java.util.Arrays.copyOf(Arrays.java:3236)
Error:  at java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:191)
Error:  at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:279)
Error:  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
Error:  at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
Error:  at com.android.dx.command.dexer.Main.processOne(Main.java:672)
Error:  at com.android.dx.command.dexer.Main.processAllFiles(Main.java:569)
Error:  at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
Error:  at com.android.dx.command.dexer.Main.run(Main.java:275)
Error:  at com.android.dx.command.dexer.Main.main(Main.java:245)
Error:  at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
Information:BUILD FAILED
Information:Total time: 3 mins 45.026 secs

My build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '23.0.3'

    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    /* Android */
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'


    /* Libraries */


}
apply plugin: 'com.google.gms.google-services'

I have added name tag in manifest:

<application
    android:name=".application.MyApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

And MyApplication extends MultiDexApplication. Why I can't build my project ?

What was wrong ?

2
  • Is instarun enabled? Commented Nov 7, 2016 at 21:45
  • Like suggested below, do a clean. Commented Nov 7, 2016 at 21:50

2 Answers 2

6

Add this line in your gradle.properties:

org.gradle.jvmargs=-Xmx1563M

Then clean and rebuild your project.

Sign up to request clarification or add additional context in comments.

2 Comments

The_Martian can you explain a little about this please?
Where is gradle.properties? I can only find gradle-wrapper.properties
-3

The solution for the above issue :

Clean and Rebuild your Project. Its working fine for me

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.