eclipse Android - MultiDex 安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27910824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android - MultiDex Install
提问by Codes
I have exceeded the 65k method limit, by importing an external library. I have enabled ProGuard, but still get the same error.
通过导入外部库,我已经超过了 65k 方法的限制。我启用了 ProGuard,但仍然出现相同的错误。
[2015-01-12 15:13:39 - Dex Loader] Unable to execute dex: method ID not in [0, 0xffff]: 65536
[2015-01-12 15:13:39 - MyFirstGame] Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
After reading the official Google documentation, it seems I should configure a MultiDex support. I am building my project using the Eclipse Indigo IDE, and do not have a build.gradle file. Using the SDK Manager I have installed 'Android Support Repository' Rev. 11 and 'Android Support Library' Rev. 21.0.3. I have added the
阅读谷歌官方文档后,看来我应该配置一个 MultiDex 支持。我正在使用 Eclipse Indigo IDE 构建我的项目,并且没有 build.gradle 文件。使用 SDK 管理器,我安装了“Android 支持库”修订版 11 和“Android 支持库”修订版 21.0.3。我已经添加了
android:name="android.support.multidex.MultiDexApplication"
attribute to my manifest file, and am now trying to implement
属性到我的清单文件,我现在正在尝试实施
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
MultiDex.install(this);
}
However, the 'MultiDex' class cannot be resolved. According to the Official Google Documentation, this jar should be located /extras/android/support/multidex/ There is no /multidex/ directory under the /support/ directory.
但是,无法解析“MultiDex”类。根据Google官方文档,这个jar应该位于/extras/android/support/multidex/ /support/目录下没有/multidex/目录。
How might I download and install the MulitDex Support Library?
我如何下载和安装 MulitDex 支持库?
回答by CommonsWare
Using the SDK Manager I have installed 'Android Support Repository' Rev. 11
使用 SDK Manager 我已经安装了“Android Support Repository”Rev. 11
That is for developers using Android Studio or other tools that use Gradle for Android. Its contents will not be presently used by standard Eclipse.
这适用于使用 Android Studio 或其他使用 Gradle for Android 的工具的开发人员。其内容目前不会被标准 Eclipse 使用。
According to the Official Google Documentation, this jar should be located /extras/android/support/multidex/
根据 Google 官方文档,这个 jar 应该位于 /extras/android/support/multidex/
Try one of these:
尝试其中之一:
Follow the instructions for adding a support library withresources, using
<sdk>/extras/android/support/multidex/library/
Copy the
<sdk>/extras/android/support/multidex/library/libs/android-support-multidex.jar
JAR into your project'slibs/
directory (since the aforementioned Android library project seems to only contain this JAR and nothing else)
按照说明添加带有资源的支持库,使用
<sdk>/extras/android/support/multidex/library/
将
<sdk>/extras/android/support/multidex/library/libs/android-support-multidex.jar
JAR复制到您的项目libs/
目录中(因为前面提到的 Android 库项目似乎只包含这个 JAR 而没有其他内容)
Do not do both. Do one or the other.
不要两者都做。做一个或另一个。
UPDATE
更新
Here is a screenshot of my <sdk>/extras/android/support/
, showing multidex/
right where the docs say it should be:
这是 my 的屏幕截图<sdk>/extras/android/support/
,显示multidex/
了文档说它应该在的位置: