sheik
sheik

Reputation: 121

Android 65k multidex issue for android system application

Developing an system application which works with multiple libraries and aar files resulting application get the Multidex 65k issue which is reported by many developers working on Android studio . In my case as am working on android system build environment not sure how to enable the multidex option ?

Have extended the Application and added MultiDex.install(this); which is making no difference for the compilation resulting

trouble writing output: Too many method references: 156862; max is 65536. You may try using --multi-dex option.

Not able to find any reference to work on the system build for this kind of issue .

Any pointers on this will be helpful

Thanks

Upvotes: 0

Views: 666

Answers (3)

ישו אוהב אותך
ישו אוהב אותך

Reputation: 29783

You can visit Configure Apps with Over 64K Methods for details.

Here some excerpt from it:

Setting up your app development project to use a multidex configuration requires that you make a few modifications to your app development project. In particular you need to perform the following steps:

  • Change your Gradle build configuration to enable multidex
  • Modify your manifest to reference the MultiDexApplication class

Modify the module-level build.gradle file configuration to include the support library and enable multidex output, as shown in the following code snippet:

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

In your manifest add the MultiDexApplication class from the multidex support library to the application element.

<?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>

UPDATE

If you have included Google Play Service library, instead using:

compile 'com.google.android.gms:play-services:9.4.0'

Try to only use what you really need. Something like this:

com.google.android.gms:play-services-base:9.4.0
com.google.android.gms:play-services-ads:9.4.0 // only need ads
com.google.android.gms:play-services-gcm:9.4.0 // only need gcm

Read more at Setting Up Google Play Services.

Upvotes: 0

Arjun saini
Arjun saini

Reputation: 4182

Update in your gradle

 defaultConfig {
  ..............

multiDexEnabled true


}

dexOptions should add..

dexOptions {
   //incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
 }

dependency add

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

Also In Your AndroidManifest.xml add this lines android:name

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

Upvotes: 2

sumandas
sumandas

Reputation: 565

Idea is if apk method is > 64K, then we break it to have multiple dex files.

In build.gradle

android {

    defaultConfig {

        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  // Add this dependency 
  compile 'com.android.support:multidex:1.0.0'
}

Hope this helps.

Reference: Android Dev

Upvotes: 0

Related Questions