Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25597

Android: Multidexed apps crash on startup on Android 4.x


    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 6.0.0
    • Fix Version/s: Release 7.0.2
    • Component/s: Android
    • Labels:
    • Story Points:


      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:

      1. Open the "tiapp.xml" file.
      2. Target Titanium SDK "7.0.0" or higher.
      3. Add module "ti.map".
      4. Add the below property to the "tiapp.xml" file. (This will increase the likeliness of the bug.)
      5. Build and run on an Android 4.x device. (The "app.js" code does not matter.)

      <?xml version="1.0" encoding="UTF-8"?>
      <ti:app xmlns:ti="http://ti.appcelerator.org">
      	<property name="android.dx.maxIdxNumber">32768</property>

      Crashes on app startup with the following logged error...

      W/dalvikvm( 2904): Unable to resolve superclass of Lcom/appcelerator/testing/ClassicapptestApplication; (4668)
      W/dalvikvm( 2904): Link of class 'Lcom/appcelerator/testing/ClassicapptestApplication;' failed
      D/AndroidRuntime( 2904): Shutting down VM
      W/dalvikvm( 2904): threadid=1: thread exiting with uncaught exception (group=0x41356300)
      D/dalvikvm( 2904): GC_CONCURRENT freed 163K, 3% free 11023K/11271K, paused 4ms+32ms, total 61ms
      E/AndroidRuntime( 2904): FATAL EXCEPTION: main
      E/AndroidRuntime( 2904): java.lang.RuntimeException: Unable to instantiate application com.appcelerator.testing.ClassicapptestApplication: java.lang.ClassNotFoundException: com.appcelerator.testing.ClassicapptestApplication

      Expected Result:
      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:


          Issue Links



              • Assignee:
                jquick Joshua Quick
                jquick Joshua Quick
                Christopher Williams
                Lokesh Choudhary
              • Watchers:
                0 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    Sync status:
                    Last received:
                    Last sent:

                    Git Integration