MultiDEX project

Alexander Yakushev edited this page Jul 23, 2015 · 2 revisions

At some point during the development you may see the following (or similar) exception:

trouble writing output: Too many field references: 68805; max is 65536.
You may try using --multi-dex option.
References by package:
     3 android
     2 android.accounts
    31 android.app
...

or

Conversion to Dalvik format failed:
Unable to execute dex: method ID not in [0, 0xffff]: 65536

This means that you’ve hit the 65k method limit which is imposed by DEX format. It usually happens after you add a few big (or many small) dependencies to your project. In order to make your project build again perform these steps:

  • In project.clj add the following lines to :android map:
    :multi-dex true
    :multi-dex-proguard-conf-path "build/proguard-multi-dex.cfg"
        
  • The file build/proguard-multi-dex.cfg should already be in your project folder if you created the project recently. Otherwise you can copy it from here.
  • Remove “incremental” from :dex-opts option in :android map. Multidexing and incremental dexing are unfortunately incompatible.
  • Make sure that you use the latest Neko version, and your application class is set to neko.App in AndroidManifest.template.xml.

    After you do these steps and rebuild your project, lein-droid will package classes into several DEX files. Multidexing build is somewhat slower but it is the only option to overcome the 65k limit.

    More about multidexing.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.