Trouble writing output,too many field reference131100 max is 65536|You may try using multi-dex option.

Android Multidex trouble writing output too many field reference

Trouble writing output, too many field reference131100 max is 65536 You may try using multi-dex option.

Are you getting this message while you are coding & making apk on android studio..

Flipkmart will solve your this issue in free .. kindly read this below article to solve your trouble writing output too many field reference issue.

Why trouble writing output,too many field reference131100 max is 65536 error happened ?

This error happens when while making android project , the number of methods increase greater than 65k methods…

How to get rid of this issue and allow more than 65k methods ?

Simple solution of this error is you need to
Enabling up Multidex .

Before enabling Multidex..

Let’s know what is Android Multidex ?

➡️ The Android virtual machine or system
Does not literally run Java byte code,, it only run dalvik byte code ..

➡️ Dexing step change /convert java byte code to dalvik byte code throughout the build procedure .

➡️ part segment of this procedure is compiling a table of every method inside the application and we are restricted to 65k methods only.

More about solving trouble writing output,too many field reference131100 max is 65536

➡️ if we want to increase number of methods more than 65 k , we tend to ask gradle to break up into multiple tables by enabling up android Multidex .

To solve “Trouble writing output,too many field reference 131100 max is 65536 ” error you need to enabling up android Multidex..

Method to implement android multidesk :-

➡️ Enabling Multidex support in Android Project

Here, we will try to learn how to enable android multidex ..

API level lower than 21: This is if your minSdkVersion is projected to lower than 21.

API level 21 & higher than that.

Kindly Note: Follow only one of the following based on the minSdkVersion in between two ⬇️

Android Multidex support for API level lower than 21

Android Multidex support for API level 21 and higher

For accomplish app code, versions of Android lower than Android 5.0 [API level 21] use the Dalvik runtime instead of java code & the limitation of using Dalvik is that ,

you unable to use more than one classes.dex bytecode file per APK.

To remove this limitation/restricson, you will have to add the Android Multidex support library.

To add the multidex support library to your android project for API level lower than 21, add the following dependency in your build.gradle file.

dependencies { implementation ‘androidx:multidex:{latest-version}’ }

If you aren’t using AndroidX, add the following support library dependency rather :

dependencies { implementation ‘com.android.support:multidex:{latest-version}’ }

By adding upon this library, your android app can head the access of additional DEX files. In simple words,, if you are having more than 64K methods,, then you will be having more than 1 DEX file & these DEX files will be control by using this multidex support library..

Then, try to modify the module-level build.gradle file to enable multidex using multiDexEnabled true.

android { defaultConfig { … minSdkVersion 15 targetSdkVersion 28 multiDexEnabled true } … } dependencies { implementation ‘androidx:multidex:{latest-version}’ }

Then, relying on whether you override the Application class, execute one of the following:-

1. If you doesn’t  override the Application class, edit your manifest file to set android:name in the <application> tag as following :-

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

2. If you do override pass over the Application class,, change it to extend MultiDexApplication (if possible) as following:-

public class MyApplication extends MultiDexApplication { … }

3. Or if you do override passover the Application class but it’s not possible to change the base class, then you can instead override the attachBaseContext() method & call MultiDex.install(this) to enabling up multidex:

public class MyApplication extends SomeOtherApplication { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } }

Now , you done your job ..

That above was all here about the API level lower than 21. Now,, let’s jump over to the next method to implement..

Multidex support for API level 21 & higher

Your task will become much easier if you are making an App for Android version 5.0 (API level 21) or higher… API level 21 utilize a runtime called ART which carry loading multiple DEX files from APK files. So,, you doesn’t  require to add the support library for multidex in Android 5.0 or higher.

Now, for API level 21 or higher,, you require to set multiDexEnabled to true in your module-level build.gradle file, as mentioned here :- ⬇️

android { defaultConfig { … minSdkVersion 21 targetSdkVersion 28 multiDexEnabled true } … }

Then,, depend upon on either you override the Application class, perform one of the following below task on 2 given scenario :–

1. If you do not override the Application class, edit your manifest file to set android:name in the <application> tag as follows:

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

2. If you do override the Application class, change it to extend MultiDexApplication (if possible) as follows:

public class MyApplication extends MultiDexApplication { … }

3. Or if you do overrule the Application class but it’s not feasible to change the base class, then you can instead override the attachBaseContext() method and call MultiDex.install(this) to enabling up multidex:

public class MyApplication extends SomeOtherApplication { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } }

Your this task is also done now..

So, now when you make your app, one primary DEX file will be constructed,, and supporting DEX files will also be added to it.. The primary DEX file is usually marked as classes.dex and other keep up DEX files as classes1.dex, classes2.dex,, and so forth..

Leave a Comment