解决安卓编译 the 64K Reference Limit

关于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 file
per 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 MultiDexApplication class

Modify the module-level build.gradle file 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 MultiDexApplication class
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>

时间: 2024-10-11 17:35:27

解决安卓编译 the 64K Reference Limit的相关文章

arduino开发过程中编译问题undefined reference to `setup&#39;的解决办法

今天遇到这个问题,搜了很久也没有找到真正的答案. 后来灵光乍现,原来是出现了相同的目标文件,既有maze.h和maze.cpp,又有maze.ino,于是编译连接的时候就会出现ld错误了. 将maze.ino重命名为任意不重复的名字,重新编译,问题解决! yeah! arduino开发过程中编译问题undefined reference to `setup'的解决办法

安卓编译出错: Process &#39;command &#39;C:\Java\jdk1.8.0_51\bin\java.exe&#39;&#39; finished with non-zero exit value 1 解决!

安卓编译出错: Process 'command 'C:\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 1 解决! 刚从eclipse转到Android studio,安装完成之后搭建了系统默认的hello world代码工程,却出现了以下错误: Process 'command 'C:\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit va

解决ndk编译lua时遇到 undefined reference to &#39;__srget&#39;的问题

今天用ndk r10d版本编译lua时,遇到几个错误,提示没有找到__srget 没有定义,于是看了国外的大神的解决方法, 是因为ndk在r10c之后的版本已经将getc函数屏蔽了,所以导致编译器找不到,只能用比较就得ndk去编译,笔者用 ndk r10b成功编译.附上r10b的下载地址:http://pan.baidu.com/s/1boUO775 转载请注明出处, from 博客园HemJohn 解决ndk编译lua时遇到 undefined reference to '__srget'的问

ubuntu12.04下安卓编译环境搭建总结

前言: 因为工作需要,经常要编译安卓下的动态库,公司有已经搭建好环境的服务器,但是第一自己想自己搭建一下了解一个整个过程,另外,公司的服务器也经常出现问 题,导致编译不了,所以就想自己搭建环境.开始是在公司自己的电脑上装了一个unbuntu的虚拟机,然后在网上找了一个攻略,开始搭建环境.但是一直卡 在源码下载那一块,每次源码下载都出错,如后面问题1所描述.断断续续,都是工作之余抽空弄一弄,但是始终下载不成功,我以为是公司网络的问题,网络不稳 定,所以下载老失败.本来想多试几次,想想总有一次会下载

[ c++] cmake 编译时 undefined reference to `std::cout&#39; 错误的解决方案

cmake ..  和 make 之后,出现如下错误 Linking CXX executable ../../../bin/ModuleTest CMakeFiles/ModuleTest.dir/tmp.cpp.o: In function `main': /ModuleTest/tmp.cpp:4: undefined reference to `std::cout' tmp.cpp 内容如下 1 #include <iostream> 2 3 int main(){ 4 std::co

解决uboot编译问题__aeabi_uidivmod&#39;和o `__aeabi_uidiv&#39;没定义的错误

undefined reference to `__aeabi_uidivmod'和undefined reference to `__aeabi_uidiv' 这个错误在uboot的编译过程中很容易出现 先分析这个原因 : 这两个函数算是lib函数 具体应用在除法应用 如果程序中使用了 '/' '%'这些运算 那就要用到这两个函数了 最简单的解决办法就是将程序中的除法都改用移位运算避免使用底层库 这里增加一个讨论为什么有些程序同样有除运算却没有这个错误提示 这就是编译器的深层问题了: Uboo

解决Use &#39;LimitInternalRecursion&#39; to increase the limit if necessary的问题 CodeIgniter .htaccess

配置.htaccess如下: RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|images|robots\.txt|css|js); RewriteRule ^(.*)$ /sis/index.php/$1 [L] Apache(error.log)报错如下: 12220:tid 1848] [client ::1:50815] AH00124: Request exceeded the limit of 10 intern

解决Cygwin编译cocos2dx 遇到的 error: &#39;UINT64_C&#39; was not declared in this scope 问题

环境工具:Win10.VS2013.cocos2d-x-2.2.6.Cygwin.ADT 问题来源:写了一个小游戏,VS2013上运行成功,就尝试着打包apk,项目导入到ADT里面,添加了cocos2dx lib库以后,讨厌的红x消失,下来就是在cygwin里面预编译得到xxx.so文件了,但是问题来了,报错!!! jni/../../Classes/GameLayer.cpp:227:46: error: 'UINT64_C' was not declared in this scope 怎么

如何解决安卓SDK无法下载Package的问题

有些用户在安装好Android SDK后,打开Android SDK Manager下载API时一直显示"Done loading packages"却迟迟不能前进.自己也出现了这种情况,把自己成功解决此问题的方法分享给大家. 方法/步骤 用户需要首先打开已下载的安卓SDK管理器"Android SDK Manager",然后点击菜单栏中的"Tools"菜单选项,接下来只需选择"Options"选项即可打开设置窗体. 接下来,