解决安卓编译 the 64K Reference Limit
2016-05-06 10:21
281 查看
关于64k 引用限制的说明
Android application (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files,which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536—including Android framework methods, library methods, and methods in your
own code. In the context of computer science, the term Kilo, K, denotes
1024 (or 2^10). Because 65,536 is equal to 64 X 1024, this limit is referred to as the '64K reference limit'.
Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as amultidex configuration.
解决方法如下
Versions of the platform prior to Android 5.0 (API level 21) use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode fileper APK. In order to get around this limitation, you can use themultidex
support library, which becomes part of the primary DEX file of your app and then manages access to the additional DEX files and the code they contain.
The Android plugin for Gradle available in Android SDK Build Tools 21.1 and higher supports multidex as part of your build configuration. Make sure you update the Android SDK Build Tools tools and the Android Support Repository to the latest version using the SDK
Manager before attempting to configure your app for multidex.
Setting up your app development project to use a multidex configuration requires that you make a few modifications to your app development project. In particular you need to perform the following steps:
Change your Gradle build configuration to enable multidex
Modify your manifest to reference the
MultiDexApplicationclass
Modify the module-level
build.gradlefile configuration to include the support library and enable multidex output, as shown in the following code snippet:
android { compileSdkVersion 21 buildToolsVersion "21.1.0" defaultConfig { ... minSdkVersion 14 targetSdkVersion 21 ... // Enabling multidex support. multiDexEnabled true } ... } dependencies { compile 'com.android.support:multidex:1.0.0' }
In your manifest add the
MultiDexApplicationclass
from the multidex support library to the application element.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.multidex.myapplication"> <application ... android:name="android.support.multidex.MultiDexApplication"> ... </application> </manifest>
相关文章推荐
- 超级炫酷的HTML5互动式程序员求职简历
- jQuerymobile 开发环境搭建
- 前端规范之命名规则
- (礼拜五log)document.cookie AND 前端图标推荐
- js、Extjs中函数的赋值和调用
- HTML&CSS
- CSS默认可继承样式
- hbase 错误:ERROR: Can't get master address from ZooKeeper; znode data == null
- caffe failed: error == cudaSuccess (2 vs. 0) out of memory
- Bootstrap的使用
- 为已存在的Hadoop集群配置HDFS Federation
- [译] 关于CSS中的float和position (父容器div内的子元素div为float时,父元素无法撑开(或高度自适应)的解决方式)
- Javascript设计模式-单例模式(一)
- jquery.validate.js 在ie8下的兼容性解决方案
- D3.js学习笔记十二:D3.js构图(d3.layout)——力学(Force)图
- HTML中使背景图片自适应浏览器大小
- [翻译]Gulp.js简介
- angular的directive的属性和用法
- 原生JS实现贪吃蛇项目,附源码下载!
- POJ 2761-Feed the dogs(划分树)求区间内第k小的数