Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25597] Android: Fixed bug where multidexed apps crash on startup on Android 4.x #9694

Merged
merged 8 commits into from Jan 24, 2018

Conversation

jquick-axway
Copy link
Contributor

@jquick-axway jquick-axway commented Dec 18, 2017

JIRA: https://jira.appcelerator.org/browse/TIMOB-25597

Notes:

  • Issue caused by "_build.js" creating a main dex class list based on target API Level, when it should have been based on min supported API Level. (Android 4.x does not natively support multidexed apps. So, we must always create this list if that is the min OS version supported, regardless of the targeted version.)
  • Modified app template to init modules via reflection. This way we don't have to add module classes to main dex file, which significantly reduces main dex class list. Especially for modules that use Google Play Services. (Avoids requiring over 64K limit in main dex file.)
  • I've verified that activities in the "AndroidManifest.xml" do not need to be in the main dex file on Android 4.x on cold startup when launched via an intent from an external app. This verifies that multidexed classes in the manifest file can be successfully loaded by the OS since our TiApplication class' call to Multidex.install() gets invoked first. Only Application derived class and the classes it used must be in main dex file.
  • Modified to run a new'ish version of ProGuard via gradle which supports Java 8 libraries instead of using the old ProGuard included with the Android SDK which support up to Java 7.
  • Fixed multidex ProGuard usage on Windows where it would fail to load multiple JAR files. (Must use semicolon ';' as a file/path array separator on that platform instead of a ':' colon.)
  • Titanium SDK now contains an Android gradle template. This is needed since the Android SDK removed the gradle template last year (it's bundled with Android Studio instead).

Test:
Run the test attached to TIMOB-25597 on:

  • Mac
  • Windows

…up on Android 4.x

- Fixed "_build.js" to create main dex class list if the min API Level is less than 21, not the target API Level.
  * Needed since Android 4.x does not support multidexed apps.
- Modified main dex class list to not include external module classes.
  * Significanlty reduces classes added to main dex list. Needed for anything using Google Play Services (adds too many APIs).
  * Modified app class template to init modules via reflection instead since module classes might not be in main dex file.
Copy link
Contributor

@garymathews garymathews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: PASS

@build build added the android label Dec 20, 2017
@build
Copy link
Contributor

build commented Dec 20, 2017

Messages
📖

💾 Here's the generated SDK zipfile.

Generated by 🚫 dangerJS

@build build added the android label Jan 9, 2018
Copy link
Contributor

@garymathews garymathews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: PASS

@lokeshchdhry
Copy link
Contributor

lokeshchdhry commented Jan 10, 2018

@jquick-axway , I get this error when I run with the fix on all android versions:

[ERROR] Application Installer abnormal process termination. Process exit value was 1
[ERROR] :  Failed to run dexer:
[ERROR] :  
[ERROR] :  Error: Can't read [/Users/lchoudhary/Desktop/android-sdk-macosx/build-tools/27.0.3/lib/shrinkedAndroid.jar] (Can't process class [android/accessibilityservice/AccessibilityService.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)))

Studio Ver: 5.0.0.201712081732
SDK Ver: 7.1.0 local build
OS Ver: 10.13.2
Xcode Ver: Xcode 9.2
Appc NPM: 4.2.11
Appc CLI: 7.0.1
Daemon Ver: 1.0.1
Ti CLI Ver: 5.0.14
Alloy Ver: 1.10.10
Node Ver: 8.9.1
NPM Ver: 5.5.1
Java Ver: 1.8.0_101
SDK Tools: 26.1.1
Platform Tools: 27.0.1
Build Tools: 27.0.3

- Added Android "gradle" build template.
  * Currently used to acquire/run newest ProGuard version. (Android SDK's ProGuard is old and doesn't support Java 8.)
  * Not used to build Android apps, yet.
- Added new "proguard.gradle" script.
  * Downloads/acquires newest ProGuard version via maven.
  * Can be used run ProGuard via gradle instead of via "java" command and the ProGuard JAR.
  * Accepts multiple ProGuard configuration files. (JAR version does not support this.)
- Fixed multidex ProGuard usage to work on Windows.
  * Was using a ':' colon as a file/path array separator instead of a ';' semicolon.
@build build added the android label Jan 23, 2018
@jquick-axway
Copy link
Contributor Author

Updated PR.

@lokeshchdhry
Copy link
Contributor

@jquick-axway , the build in jenkins is failing at linting. Can you please check.

@build build added the android label Jan 23, 2018
@lokeshchdhry
Copy link
Contributor

FR Passed.

No crash seen after launch on android 4.X.

Studio Ver: 5.0.0.201712081732
SDK Ver: 7.1.0 local build
OS Ver: 10.13.2
Xcode Ver: Xcode 9.2
Appc NPM: 4.2.11
Appc CLI: 7.0.1
Daemon Ver: 1.0.1
Ti CLI Ver: 5.0.14
Alloy Ver: 1.10.10
Node Ver: 8.9.1
NPM Ver: 5.5.1
Java Ver: 1.8.0_101
Emulator: Android 4.4.2, Android 4.4.4

@mukherjee2 mukherjee2 self-requested a review January 24, 2018 23:33
Copy link
Contributor

@mukherjee2 mukherjee2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed FR on Windows. Details are in back port version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants