如何处理 android 方法总数超过 65536 . the number of method references in a .dex file exceed 64k

简介: 一:问题描述:     应用中的Dex 文件方法数超过了最大值65536的上限,简单来说,应用爆棚了.   二、解决方案:      方案1:使用插件化框架  比如: https://github.
一:问题描述:

    应用中的Dex 文件方法数超过了最大值65536的上限,简单来说,应用爆棚了.

 

二、解决方案:

     方案1:使用插件化框架  比如: https://github.com/singwhatiwanna/dynamic-load-apk

    方案2:分割Dex

 

三:分割 Dex 文件实现方法 

     1、相关链接

     https://developer.android.com/tools/building/multidex.html#about

     2、在app的 build.gradle 中

         (1)在dependencies 中添加  

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

         (2)在 defaultConfig 中添加

                multiDexEnabled true

                     比如   

1  defaultConfig {
2         applicationId "com.pegasus.map"
3         minSdkVersion 15
4         targetSdkVersion 23
5         versionCode 1
6         versionName "1.0"
7         signingConfig signingConfigs.config
8         multiDexEnabled true
9     }

         (3)在 AndroidManifest.xml 中的  application 标签中添加             

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     <application
5         ...
6         android:name="android.support.multidex.MultiDexApplication">
7         ...
8     </application>
9 </manifest>

   提示:如果你的应用程序继承 Application , 那么你需要重写     

1 @Override
2     protected void attachBaseContext(Context base) {
3         super.attachBaseContext(base);
4         MultiDex.install(this) ;
5     }

 

另外我的微信公众账号是: zhaoyanjun125  

我会经常发一些我的些项目的感悟和编程技术。欢迎关注。

 微信扫描二维码 关注我

  

 

 

 

 

        

 

相关文章
|
2月前
|
开发工具 Android开发
X Android SDK file not found: adb.安卓开发常见问题-Android SDK 缺少 `adb`(Android Debug Bridge)-优雅草卓伊凡
X Android SDK file not found: adb.安卓开发常见问题-Android SDK 缺少 `adb`(Android Debug Bridge)-优雅草卓伊凡
440 11
X Android SDK file not found: adb.安卓开发常见问题-Android SDK 缺少 `adb`(Android Debug Bridge)-优雅草卓伊凡
【Bug】Android resource linking failed和error: failed linking references.
【Bug】Android resource linking failed和error: failed linking references.
|
开发工具 Android开发
解决Android运行出现NDK at /Library/Android/sdk/ndk-bundle did not have a source.properties file
解决Android运行出现NDK at /Library/Android/sdk/ndk-bundle did not have a source.properties file
1005 4
解决Android运行出现NDK at /Library/Android/sdk/ndk-bundle did not have a source.properties file
|
数据库 Android开发 数据库管理
java.lang.NullPointerException: Attempt to invoke virtual method ‘int android.database.sqlite异常
java.lang.NullPointerException: Attempt to invoke virtual method ‘int android.database.sqlite异常
764 0
|
Shell Go 开发工具
How to decompile Google Android .apk file as readable dump【原创】
How to decompile Google Android .apk file as readable dump【原创】
144 0
|
Android开发
Can t process attribute android:fillColor=@color/camera_progress_delete: references to other resou
Can t process attribute android:fillColor=@color/camera_progress_delete: references to other resou
|
Java Android开发
Android编译的jar里面是dex
Android编译的jar里面是dex
216 0
|
Android开发
安卓逆向 -- Hook多个dex文件
安卓逆向 -- Hook多个dex文件
142 1
|
XML Android开发 数据格式
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class
184 0

热门文章

最新文章