android - The number of method references in a .dex file exceed 64K -


currently working on android application after including play services , firebase library in project i'm getting error , unable run code

:app:prepackagemarkerfordebug :app:transformclasseswithdexfordebug run dex in process, gradle daemon needs larger heap. has approximately 910 mb. faster builds, increase maximum heap size gradle daemon more 2048 mb. set org.gradle.jvmargs=-xmx2048m in project gradle.properties. more information see https://docs.gradle.org/current/userguide/build_environment.html error:the number of method references in .dex file cannot exceed 64k. learn how resolve issue @ https://developer.android.com/tools/building/multidex.html :app:transformclasseswithdexfordebug failed error:execution failed 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_60.jdk/contents/home/bin/java'' finished non-zero exit value 2

my build.gradle file here :

apply plugin: 'com.android.application'  android { compilesdkversion 23 buildtoolsversion "23.0.2"  defaultconfig {     applicationid "xyz.in.network"     minsdkversion 16     targetsdkversion 23     versioncode 1     versionname "1.0" } buildtypes {     release {         shrinkresources true         minifyenabled true         proguardfiles getdefaultproguardfile('proguard-android-optimize.txt'), 'proguard-rules.pro'         multidexenabled true     } } }  dependencies {    compile filetree(dir: 'libs', include: ['*.jar'])    testcompile 'junit:junit:4.12'    compile project(':libs:viewpagerindicator')    compile 'com.google.android.gms:play-services:9.0.0'    compile 'com.android.support:appcompat-v7:23.4.0'    compile 'com.android.support:design:23.4.0'    compile 'com.google.android.gms:play-services-maps:9.0.0'    compile 'com.google.android.gms:play-services-location:9.0.0'    compile 'com.android.support:cardview-v7:23.4.0'    compile 'com.getbase:floatingactionbutton:1.10.1'    compile 'com.squareup.picasso:picasso:2.5.2'    compile 'com.android.volley:volley:1.0.0'    compile 'com.google.firebase:firebase-messaging:9.0.0'    compile 'com.android.support:multidex:1.0.1'    }     apply plugin: 'com.google.gms.google-services' 

and manifestfile here

<application     android:allowbackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:name="android.support.multidex.multidexapplication"     android:supportsrtl="true"     android:theme="@style/apptheme"> <activity android:name=".util.disconnectednetwork"         android:screenorientation="portrait"         android:theme="@style/theme.transparent"></activity>      <service android:name=".fcm.firebasemessaginghandler">         <intent-filter>             <action android:name="com.google.firebase.messaging_event"/>         </intent-filter>     </service>      <service android:name=".fcm.firebaseregistrationtokenhandler">         <intent-filter>             <action android:name="com.google.firebase.instance_id_event"/>         </intent-filter>     </service>      <meta-data         android:name="com.google.android.gms.version"         android:value="@integer/google_play_services_version" />  </application> 

after increasing heap size 2048m. gradle give error

error:execution failed 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

i follow instruction given on android developer site still got problem. how solve problem?

you need enable multidex in android default config then:

android {     compilesdkversion 23     buildtoolsversion '23.0.3'      defaultconfig {         applicationid "com.example.case"         minsdkversion 16         targetsdkversion 23         versioncode 43         versionname "4.0.13"          // enabling multidex support.         multidexenabled true     } 

when building application in daily routine, use debug default flavor. if application has more 65k method, need ot enable on flavor.

as side note, may want use proguard on debug build won't have enable multidex on it.

full app/build.gradle (documentation)

android {     compilesdkversion 21     buildtoolsversion "21.1.0"      defaultconfig {         ...         minsdkversion 14         targetsdkversion 21         ...          // enabling multidex support.         multidexenabled true     }     ... }  dependencies {   compile 'com.android.support:multidex:1.0.1' } 

last part: add multidex application in manifest (or parent of own application

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.android.multidex.myapplication">     <application         ...         android:name="android.support.multidex.multidexapplication">         ...     </application> </manifest> 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -