【Android】-- 处理 android 方法总数超过 65536 . the number of method references in a .dex file exceed 64k的两种办法

一:问题描述:

    应用中的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     }
 
 
 
 
转子:http://www.cnblogs.com/zhaoyanjun/p/5390690.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值