How to deal with android methods that exceed 65536. the number of method references in a. dex file exceed 64 k, android. dex

Source: Internet
Author: User

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

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.