您的位置:首页 > 移动开发 > Android开发

Android配置方法数超过 64K 的应用

2017-02-20 15:52 435 查看
Android Studio运行提示:

Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html[/code] 
官方有提供了原因分析与解决方法:https://developer.android.com/studio/build/multidex.html?hl=zh-cn

下面做下简单总结解决步骤:

1、在build.gradle里面加入multiDexEnabled true

defaultConfig {
minSdkVersion 14
targetSdkVersion 21

// Enabling multidex support.
multiDexEnabled true
}


2、添加依赖包

/**dex分包*/
compile 'com.android.support:multidex:1.0.0'


3、在Application里面重写 attachBaseContext 方法

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}


问题解决。

参考:http://blog.5ibc.net/p/85377.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  64K dex