Android: my application is too large and gives “Unable to execute dex: method ID not in [0, 0xffff]: 65536”?

前端 未结 8 2052
慢半拍i
慢半拍i 2020-11-27 04:52

I am trying to integrate my application with Box, Dropbox, and Google Drive. All 3 of these services require a number of 3rd party jars. Additionally, my application alrea

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 04:53

    ***NEW**** All of the other answers are now outdated. Here's the new fix

    Android 5.0 and higher

    Multi-dex support is included automatically. From the docs:

    Android 5.0 and higher uses a runtime called ART which natively supports loading multiple dex files from application APK files. ART performs pre-compilation at application install time which scans for classes(..N).dex files and compiles them into a single .oat file for execution by the Android device. For more information on the Android 5.0 runtime, see Introducing ART.

    Below Android 5.0

    Simply add the Android mult-dex support tool to your gradle build:

    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'
    }
    

提交回复
热议问题