7

Is there a way to set enable multidex (https://github.com/casidiablo/multidex) for Android if I build apps using Ionic Framework ?

Redturbo
  • 1,543
  • 8
  • 22
  • 34
  • View, I things same problem [Cordova - Multiple dex files define (annotation)](http://stackoverflow.com/questions/31727318/cordova-multiple-dex-files-define-annotation/33777507#33777507) – Anurag Pandey Dec 14 '15 at 06:58

5 Answers5

6

There is a plugin that enables multidex. To install it, run:

cordova plugin add --save https://github.com/jwall149/cordova-multidex

And try building again. The build may take a little longer than usual, but your app should compile without troubles.

Grayda
  • 1,641
  • 2
  • 22
  • 41
5

For those still having this issue, I've fixed it by installing cordova-plugin-multidex

cordova plugin add cordova-plugin-enable-multidex

Check it out: Multidex for Cordova

nnimis
  • 424
  • 8
  • 15
3

For people using androidx and cordova-android: 8 is interested in this solution, I created a fork that supports the file structure and class names of these new versions. Also works with Ionic.

cordova plugin add --save https://github.com/c00/cordova-multidex

Note that this is only relevant if you are still supporting a minSdk less than 21. At 21, multidexing is no longer needed as there is some built-in fix for it. So in that case, just remove the multidex plugin (if you had it) and things should work.

Coo
  • 1,727
  • 3
  • 18
  • 36
1

Try this

cordova plugin add --save https://github.com/jwall149/cordova-multidex
Muhammad Mubeen
  • 123
  • 1
  • 8
1
To fix this —

Install couple of androidx plugins to solve the issue. So simply run the following commands in your project root:

Add plugin to enable AndroidX in the project

1. ionic cordova plugin add cordova-plugin-androidx

2. Add plugin to patch existing plugin source that uses the Android Support Library to use AndroidX

ionic cordova plugin add cordova-plugin-androidx-adapter

3. Now run the following commands in your project root:

cordova clean
ionic cordova build android

https://medium.com/@AnkitMaheshwariIn/ionic-android-error-while-merging-dex-archives-unable-to-merge-dex-in-ionic-3f6272899aab

Shashwat Gupta
  • 4,435
  • 36
  • 28