Android - MultiDex Install

只愿长相守 提交于 2020-01-11 11:19:50

问题


I have exceeded the 65k method limit, by importing an external library. I have enabled ProGuard, but still get the same error.

[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

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.

How might I download and install the MulitDex Support Library?


回答1:


Using the SDK Manager I have installed '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.

According to the Official Google Documentation, this jar should be located /extras/android/support/multidex/

Try one of these:

  1. Follow the instructions for adding a support library with resources, using <sdk>/extras/android/support/multidex/library/

  2. Copy the <sdk>/extras/android/support/multidex/library/libs/android-support-multidex.jar JAR into your project's libs/ directory (since the aforementioned Android library project seems to only contain this JAR and nothing else)

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:



来源:https://stackoverflow.com/questions/27910824/android-multidex-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!