When adding several heavy weight Android modules such as "ti.map" and its "ti.playservices" dependency, the app will most likely crash on startup on Android 4.x. This is not an issue on Android 5.0 and above since those OS versions have built-in support for multidexed apps.
Steps to Reproduce:
- Open the "tiapp.xml" file.
- Target Titanium SDK "7.0.0" or higher.
- Add module "ti.map".
- Add the below property to the "tiapp.xml" file. (This will increase the likeliness of the bug.)
- Build and run on an Android 4.x device. (The "app.js" code does not matter.)
Crashes on app startup with the following logged error...
Should not crash. (We've added the Google multidex support library with the intention of multidex support on Android 4.x.)
Android 4.x does not have built-in multidex support. So, we have to add support by calling the Google support library's "MultiDex.install()" from the application class which we're already doing now. But in order to do this, Titanium's application class and all of the classes it uses must be embedded in the main dex file or else the Java runtime will fail to lazy load them on startup. We must specify which Java classes must be embedded in the main dex file by using the "--main-dex-list" command line argument when building a multidexed app.
This issue is more likely to happen with Titanium 7.0.0 when using any module that uses Google Play Services. This is because our new "ti.playservices" includes a much higher public API count that'll trigger multidexed builds.
This was raised: