Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24446] Android: Allow user to specify Android Support Library version

GitHub Issuen/a
TypeImprovement
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-05-23T21:27:56.000+0000
Affected Version/sRelease 6.0.2
Fix Version/sRelease 6.1.0
ComponentsAndroid
Labelsmerge-6.2.0
ReporterJan Vennemann
AssigneeJan Vennemann
Created2017-03-02T02:01:00.000+0000
Updated2017-11-10T23:30:07.000+0000

Description

As of now we bundle a specific version of the Android Support Library with Titanium. Due to frequent updates to this library we should consider to allow users to use another version than our bundled one. Some general thoughts on this: - Build on-top of AAR handling introduced in TIMOB-18565 and make use of installed Support Libraries in ${ANDROID_SDK}/extras/android/m2repository/com/android/support - Allow users to override the bundled one via config option, e.g. android.supportLibrary.selectedVersion or on a per-project base? - Utilize a hook to check if a custom version is set, extract into the build dir and integrate it. Cache on subsequent builds. This ticket is for further evaluation of this topic. *Additional Notes* - Hyperloop contains a special case handling for the Android support library in the Android plugin hook

Attachments

FileDateSize
com.appc.timob24446-6_2_X-android-1.0.0.zip2017-08-03T15:41:56.000+00003323514
com.appc.timob24446-android-1.0.0.zip2017-07-21T03:14:15.000+000064725

Comments

  1. Peter Steinberger 2017-04-04

    Found this issue through the somewhat related AAR support issue [TIMOB-18565] Locking in on old support libraries is a big problem in the Android ecosystem. At https://pspdfkit.com, we are running into the same issue with Xamarin Forms and now Titanium. As the Android Support libs are basically *essential* to build Android apps and also can't coexist, the only sane path here is that everyone works hard to always keeps the deps up to date or allows to configure the version used. PSPDFKit for Android currently requires v25.3 of the support library. and it's not possible to downgrade that because older versions have some bugs that we had to fix by updating. We always try to be on the most current version available to reduce version mismatch with our customers. We're already testing v26 and will adopt that as soon as it's stable - major versions of the support library correspond with target OS version and it's important for us to support the new features of Android O as soon as it's out. Integration guide: https://pspdfkit.com/guides/android/current/getting-started/integrating-pspdfkit/ v26 Support Library Docs: https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0-alpha1
  2. Jan Vennemann 2017-05-02

    PR: https://github.com/appcelerator/titanium_mobile/pull/9008
  3. Jan Vennemann 2017-05-18

    [~lchoudhary], sorry for the delay, had to fix TIMOB-24703 first to create a proper test case for this one. That also means TIMOB-24703 has to be resolved first before this can be properly tested. PR (6_1_X): https://github.com/appcelerator/titanium_mobile/pull/9070 *Steps to test*

    Extract the attached test module and add it to a new app

    Replace the content of app/controllers/index.js with:

       //var AarModule = require('com.appc.aarmodule');
       var bottomNavigation = require('com.appc.timob24446');
       $.index.add(bottomNavigation.createExample());
       $.index.open();
       

    Remove the <Label> tag from app/views/index.html

    Run the app

    *Expected behavior* The app shows a bottom navigation bar with two items. If you tap on one of the items, the label changes its text corresponding to the item tapped.
  4. (deactived) Brian Immel 2017-05-19

    [~jvennemann], does this sound like a good summary for the release note: "Added support to allow users to specify which version of the Android Support Library to use with Titanium"
  5. Samir Mohammed 2017-05-19

    [~jvennemann] If Hyperloop is enabled I get the following error:
       [ERROR] :  Failed to run dexer:
       [ERROR] :  
       [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
       [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatJellyBeanMr2;
       [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/AnimatorListenerCompat;
       [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/AnimatorProvider;
       [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/AnimatorUpdateListenerCompat;
       [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/HoneycombMr1AnimatorCompatProvider;
       [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/HoneycombMr1AnimatorCompatProvider$AnimatorListenerCompatWrapper;
       [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/HoneycombMr1AnimatorCompatProvider$HoneycombValueAnimatorCompat;
       [ERROR] :  Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/HoneycombMr1AnimatorCompatProvider$HoneycombValueAnimatorCompat$1;
       [ERROR] :  
       [ERROR] :  UNEXPECTED TOP-LEVEL EXCEPTION:
       [ERROR] :  java.lang.RuntimeException: Translation has been interrupted
       [ERROR] :  	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:613)
       [ERROR] :  	at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
       [ERROR] :  	at com.android.dx.command.dexer.Main.run(Main.java:275)
       [ERROR] :  	at com.android.dx.command.dexer.Main.main(Main.java:245)
       [ERROR] :  	at com.android.dx.command.Main.main(Main.java:106)
       [ERROR] :  Caused by: java.lang.InterruptedException: Too many errors
       [ERROR] :  	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:605)
       [ERROR] :  	... 4 more
       
  6. Jan Vennemann 2017-05-23

    [~lchoudhary], updated both PRs to fix the Hyperloop issue. Please note that the master PR is already set to only work with TIMOB-24664.
  7. Lokesh Choudhary 2017-05-23

    FR for backport PR done & PR merged.
  8. Muhammad Ahmed Fahad 2017-05-24

    How can we specify the Android Support Library version?
  9. Jan Vennemann 2017-05-24

    [~fahad86], i'm currently writing some docs for that, they should be available shorty at the [Android Module Project Guide](https://wiki.appcelerator.org/display/guides2/Android+Module+Project). Basically what you have to do is copy the .aar files of the Android Support Libraries version you want from your Android SDK <andriod-sdk>/extras/android/m2repository/com/android directory into your modules lib directory. Please note that you have to copy all of it's dependencies too, so if you want to use support-v4 25.3.1 for example, you have to copy these .aar files:
       support-v4-25.3.1.aar
       support-compat-25.3.1.aar
       support-core-ui-25.3.1.aar
       support-core-utils-25.3.1.aar
       support-fragment-25.3.1.aar
       support-media-compat-25.3.1.aar
       
    This is currently the only way to do it because we can't utilize gradle to automatically resolve dependencies. The docs will contain some tips how you can easily resolve them on your own.
  10. Brandon Fuller 2017-07-30

    I have been waiting on this so thanks for moving it forward. I went and got a nightly build of the SDK 6.2.0.v20170727074842. Tried it in my project but I am seeing errors in the build because of support-v4. I am trying to integrate with Intercom's Android Library (https://github.com/intercom/intercom-android). They use Android Support 25.3.1 as in the last comment above. So I put all those files plus some others into my module's lib. The directory looks like: android-composer-1.2.2.aar android-composer-gallery-1.2.2.aar appcompat-v7-25.3.1.aar design-25.3.1.aar intercom-sdk-base-3.2.8.aar intercom-sdk-gcm-3.2.8.aar recyclerview-v7-25.3.1.aar support-compat-25.3.1.aar support-core-ui-25.3.1.aar support-core-utils-25.3.1.aar support-fragment-25.3.1.aar support-media-compat-25.3.1.aar support-v4-25.3.1.aar support-vector-drawable-25.3.1.aar Then when I build I get: [ERROR] : Failed to run dexer: [ERROR] : [ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs; [ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatJellyBeanMr2; [ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/AnimatorListenerCompat; [ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/AnimatorProvider; [ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/AnimatorUpdateListenerCompat; [ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/HoneycombMr1AnimatorCompatProvider; [ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/HoneycombMr1AnimatorCompatProvider$AnimatorListenerCompatWrapper; [ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/HoneycombMr1AnimatorCompatProvider$HoneycombValueAnimatorCompat; [ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/HoneycombMr1AnimatorCompatProvider$HoneycombValueAnimatorCompat$1; [ERROR] : When I look at the command line for the dexer I see: "/Users/bfuller/Library/Application Support/Titanium/mobilesdk/osx/6.2.0.v20170727074842/android/android-support-v4.jar" So maybe it is still including the SDK's support lib? I see mine in there too: "/Users/bfuller/Documents/Appcelerator_Studio_Workspace/Attorney/build/android/intermediates/exploded-aar/support-v4-25.3.1/classes.jar" Any ideas?
  11. Jan Vennemann 2017-07-31

    [~brandonfuller], the 6.2.0 nightlies currently do not have this feature because of a dependency to TIMOB-24664. The PR for that ticket was recently merged so this one will follow soon. In the meantime you can try with the recent 6.1.1 GA which already comes with this feature!
  12. Brandon Fuller 2017-07-31

    Thanks for pointing out my error. I didn't follow the commit push history correctly. I retried with 6.1.1.GA and it worked. So I concur that you can now overwrite the support library dependency. One note, you have to use the same Android SDK as you use for the support library. May be obvious but I had forgotten to update the manifest to include the proper target version:
  13. Jan Vennemann 2017-08-03

    [~brandonfuller], that may be something we can add to the docs. Added that to TIMOB-25062 so it will be mentioned along with the improved workflow how to replace Android Support Libraries. [~lchoudhary], i attached com.appc.timob24446-6_2_X-android-1.0.0.zip which includes a test module for the 6_2_X branch PR. Steps to test:

    Place the module in an app and add it to the tiapp.xml (identifier is still com.appc.timob24446)

    Run the app with trace logging enabled, no special use of the module required

    During the build, it should log several of the following messages to the console, that indicate one of our bundled Support Libraries has been replaced:

        [TRACE] Android library /Users/jvennemann/Development/appc/aar-app/modules/android/com.appc.timob24446/1.0.0/lib/appcompat-v7-25.4.0.aar (android.support.v7.appcompat) available, marking /Users/jvennemann/Library/Application Support/Titanium/mobilesdk/osx/6.2.0/android/android-support-v7-appcompat.jar to be excluded.
        

    After that app started you should see this log, indicating that an API that is was introduced in 25.4.0 is available:

        [INFO]  I/System.out: Method MediaBrowserCompat.sendCustomAction available!
        
  14. Brandon Fuller 2017-08-03

    This might not be appropriate in this JIRA but when I went to use Android Support Library 25.3 I ran into an error on app load. This may be due to incompatible changes in support-v4-25.3.1.aar. Looks like they moved a static method that Titanium uses to be a private member. I guess these breaking changes will make it hard to have compatibility. Hopefully, Titanium moves to v25 soon? [WARN] : W/System.err: java.lang.NoSuchMethodError: No static method addAccessibilityStateChangeListener(Landroid/view/accessibility/AccessibilityManager;Landroid/support/v4/view/accessibility/AccessibilityManagerCompat$AccessibilityStateChangeListenerCompat;)Z in class Landroid/support/v4/view/accessibility/AccessibilityManagerCompat; or its super classes (declaration of 'android.support.v4.view.accessibility.AccessibilityManagerCompat' appears in /data/app/com.localcounselcollective.mobile.iphone.localcounsel-1/base.apk) [WARN] : W/System.err: at ti.modules.titanium.app.AppModule.onHasListenersChanged(AppModule.java:220) [WARN] : W/System.err: at org.appcelerator.kroll.KrollObject.setHasListenersForEventType(KrollObject.java:70) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:196) [WARN] : W/System.err: at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:319) [WARN] : W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98) [WARN] : W/System.err: at android.os.Looper.loop(Looper.java:148) [WARN] : W/System.err: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)
  15. Jan Vennemann 2017-08-03

    6_2_X backport: https://github.com/appcelerator/titanium_mobile/pull/9275 [~brandonfuller], according to the docs the static method was deprecated in 26.0.0, so it should still be there with Support Library 25.3.1. Please open a new ticket if the issue persists so we don't spam this one with comments. And last but not least: Titanium 6.2.0 will contain Support Library Revision 25.3.1, see TIMOB-24664 ;)
  16. Lokesh Choudhary 2017-08-03

    FR passed for backport PR https://github.com/appcelerator/titanium_mobile/pull/9275 PR merged.
  17. Lokesh Choudhary 2017-11-10

    Merged master PR. Closing.

JSON Source