How to deal with android methods that exceed 65536. the number of method references in a. dex file exceed 64 k, android. dex
I. Problem description:
The number of Dex file methods in the application exceeds the upper limit of 65536. In short, the application burst.
Ii. solution:
Solution 1: Use a plug-in framework such as: https://github.com/singwhatiwanna/dynamic-load-apk
Solution 2: Split Dex
Iii. How to split Dex files
1. Related Links
Https://developer.android.com/tools/building/multidex.html#about
2. In app build. gradle
(1) Add in dependencies
Compile 'com. android. support: multidex: 1.0.0'
(2) Add in defaultConfig
MultiDexEnabled true
For example
1 defaultConfig {2 applicationId "com.pegasus.map"3 minSdkVersion 154 targetSdkVersion 235 versionCode 16 versionName "1.0"7 signingConfig signingConfigs.config8 multiDexEnabled true9 }
(3) Add the application tag in AndroidManifest. xml
1 <?xml version="1.0" encoding="utf-8"?>2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"3 package="com.example.android.multidex.myapplication">4 <application5 ...6 android:name="android.support.multidex.MultiDexApplication">7 ...8 </application>9 </manifest>
Tip: if your Application inherits the Application, you need to rewrite it.
1 @Override2 protected void attachBaseContext(Context base) {3 super.attachBaseContext(base);4 MultiDex.install(this) ;5 }
In addition, my public account is zhaoyanjun125.
I will often learn some of my project insights and programming technologies. Welcome.
Scan QR code to follow me