[AC-5431] Android: Enable Multi-Dex support for Android 4.X.X
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Done |
Resolution Date | 2018-01-03T22:02:57.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Muhammad Ahmed Fahad |
Assignee | Shak Hossain |
Created | 2017-12-08T08:18:43.000+0000 |
Updated | 2018-01-24T01:11:23.000+0000 |
Description
Currently we have multi-dex support and have made it default which enables us compiling apps with massive libraries and works fine for Android 5+. But when the number of method goes above 65K the app completely stops working on Android 4.X.X which the SDK still claims to support.
Here is what is mentioned in the Android Studio doc to enable multi-dex for devices running Android versions which were prior to 5.0.0: *[https://developer.android.com/studio/build/multidex.html#mdex-pre-l](https://developer.android.com/studio/build/multidex.html#mdex-pre-l)*
I tried changing the android application name, i.e.:
*
*as mentioned in: [https://developer.android.com/studio/build/multidex.html#mdex-pre-l](https://developer.android.com/studio/build/multidex.html#mdex-pre-l)
but while trying to run the application, the app crashes with the error:
E/AndroidRuntime(32659): java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.xyz/com.xyz.XYZActivity}
: java.lang.ClassCastException: android.support.multidex.MultiDexApplication cannot be cast to org.appcelerator.titanium.TiApplication
Or how can I override the attachBaseContext method on the Main application class?
???
Hello, Can you share a sample app that we can test to verify the issue in Android 4.x.x and also see the response in 5.x.x and above. Please provide a sample app and list of steps to follow for successful regeneration. Thanks.
[~jquick] Thoughts?
I've confirmed that multidex support for Android 4.x isn't reliable and will mostly likely crash on app startup. For now, the only reliable work-around is to set the min supported Android OS version to 5.0 by adding the following to your "tiapp.xml" file...
*Technical Reason:* The Titanium build tools needs to embed the "TiApplication" Java class and all of the Java classes it uses into the main dex file. This is because the application class needs to enable multidex support on Android 4.x, but the application class and its members need to be loaded successfully from the main dex file before doing so. This involves us passing a "--main-dex-list" command line argument when building a multidex app. This will never be a problem on Android 5.0 and above since those OS versions have built-in multidexing support.
This issue will be resolved by the fix for [TIMOB-25597] in Titanium 7.0.2.
Closing as duplicate.