Too many field references

If your error looking similar to the following error messages, this document would help

Conversion to Dalvik format failed:
Unable to execute dex: method ID not in [0, 0xffff]: 65536

OR

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

 

If an app was previously approaching the 64K reference limit, enabling Hansel may push it over this limit as we add close to 900 methods. The solution requires changes in build.gradle and the Application class.

Changes in build.gradle

Modify your app Gradle build file configuration to include the support library and enable multidex output, as shown in the following Gradle build file 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'
} 


Have your class, which directly extends Application, extend MultiDexApplication instead of Application. If you don’t have such a class, add it, as you would need it for the sdk to work properly. Read SDK Usage section for details.Changes in Application class

OR

If your application class extends Application indirectly through some class of a library, have your class override the function attachBaseContext using the following code.


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


Learn more on this issue from
developer docs of Android. 



Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.