Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24799] Android: Theme Causing Issues in SDK 6.2.2.GA

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2017-06-12T20:49:06.000+0000
Affected Version/sRelease 6.1.0, Release 6.0.4
Fix Version/sRelease 6.1.1
ComponentsAndroid
Labelsn/a
Reporter Ricardo Ramirez
AssigneeEwan Harris
Created2017-06-08T21:31:14.000+0000
Updated2017-07-20T20:33:46.000+0000

Description

Issue Description

Creating an Appcelerator project targeting Android that uses the Titanium theme using 6.2.2.GA causes certain UI elements to not work. In some cases, this results in warning messages being logged and no activity, in others, errors are logged and an error dialog appears in the app, and in others, the app crashes entirely. The cases that we have identified so far are: optionDialogs, alertDialogs, and switches; however, considering the theming of many items also appears to have been changed unexpectedly, it seems likely that there are issues occurring with other elements that we have not noticed.

Steps to replicate

Here's a github link to a project that recreates the issues I've mentioned: https://github.com/bbuehler-axway-support/android-titanium-theme Please note that in this project, for the switch element, we are adding this via JavaScript in the controller, rather than creating an XML version. This is because creating an XML version causes the app to crash immediately on loading the page, which isn't terribly useful for testing. Additionally, as I do not see any changes to the Titanium Theme mentioned in the release notes, I would expect that rather than the Titanium Theme changing, other changes to Android in this SDK version have caused compatibility issues with the theme.

Comments

  1. Ewan Harris 2017-06-09

    I can reproduce this issue on the below environment. If I comment out the code in [this commit](https://github.com/appcelerator/titanium_mobile/pull/8911/commits/0ebe4cc66866cea2966f5a9b7fc73d320059b51b) the issue does not occur OnePlus 3: 7.1.1 Ti SDK: 6.0.4.GA, 6.1.0.GA, 6.1.1.v20170608162457

    Steps to reproduce

    Download the application in the descripton

    Run the application to Android device

    Tap a button

    Actual

    When I tap on Add Switch, the below error is thrown
       [ERROR] TiApplication: (main) [5679,5679] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference; Titanium 6.0.4,2017/04/26 14:02,undefined
       [ERROR] TiApplication: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference
       [ERROR] TiApplication:  at android.text.StaticLayout.<init>(StaticLayout.java:432)
       [ERROR] TiApplication:  at android.support.v7.widget.SwitchCompat.makeLayout(SwitchCompat.java:602)
       [ERROR] TiApplication:  at android.support.v7.widget.SwitchCompat.onMeasure(SwitchCompat.java:522)
       [ERROR] TiApplication:  at android.view.View.measure(View.java:19955)
       [ERROR] TiApplication:  at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:445)
       [ERROR] TiApplication:  at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:303)
       [ERROR] TiApplication:  at android.view.View.measure(View.java:19955)
       [ERROR] TiApplication:  at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:445)
       [ERROR] TiApplication:  at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:303)
       [ERROR] TiApplication:  at android.view.View.measure(View.java:19955)
       [ERROR] TiApplication:  at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:445)
       [ERROR] TiApplication:  at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:303)
       [ERROR] TiApplication:  at android.view.View.measure(View.java:19955)
       [ERROR] TiApplication:  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6087)
       [ERROR] TiApplication:  at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
       [ERROR] TiApplication:  at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
       [ERROR] TiApplication:  at android.view.View.measure(View.java:19955)
       [ERROR] TiApplication:  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6087)
       [ERROR] TiApplication:  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
       [ERROR] TiApplication:  at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
       [ERROR] TiApplication:  at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
       [ERROR] TiApplication:  at android.view.View.measure(View.java:19955)
       [ERROR] TiApplication:  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6087)
       [ERROR] TiApplication:  at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
       [ERROR] TiApplication:  at android.view.View.measure(View.java:19955)
       [ERROR] TiApplication:  at android.widget.LinearLayout.measureVertical(LinearLayout.java:911)
       [ERROR] TiApplication:  at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
       [ERROR] TiApplication:  at android.view.View.measure(View.java:19955)
       [ERROR] TiApplication:  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6087)
       [ERROR] TiApplication:  at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
       [ERROR] TiApplication:  at com.android.internal.policy.DecorView.onMeasure(DecorView.java:689)
       [ERROR] TiApplication:  at android.view.View.measure(View.java:19955)
       [ERROR] TiApplication:  at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2309)
       [ERROR] TiApplication:  at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1392)
       [ERROR] TiApplication:  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1645)
       [ERROR] TiApplication:  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1280)
       [ERROR] TiApplication:  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6432)
       [ERROR] TiApplication:  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
       [ERROR] TiApplication:  at android.view.Choreographer.doCallbacks(Choreographer.java:686)
       [ERROR] TiApplication:  at android.view.Choreographer.doFrame(Choreographer.java:621)
       [ERROR] TiApplication:  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
       [ERROR] TiApplication:  at android.os.Handler.handleCallback(Handler.java:751)
       [ERROR] TiApplication:  at android.os.Handler.dispatchMessage(Handler.java:95)
       [ERROR] TiApplication:  at android.os.Looper.loop(Looper.java:154)
       [ERROR] TiApplication:  at android.app.ActivityThread.main(ActivityThread.java:6290)
       [ERROR] TiApplication:  at java.lang.reflect.Method.invoke(Native Method)
       [ERROR] TiApplication:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
       [ERROR] TiApplication:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
       

    Expected

    The UI element corresponding to the button tapped should be added, i.e Add switch adds a switch
  2. Gary Mathews 2017-06-09

    [~rramirez] Theme.Titanium inherits the theme set in <application android:theme="...", in your tiapp.xml you are doing this:
       <application android:theme="@style/Theme.Titanium"/>
       
    So Theme.Titanium is inheriting itself, which is bad. Just remove that line, or use a different name for your theme. We should add validation to prevent this from happening.
  3. Ewan Harris 2017-06-09

    Master: https://github.com/appcelerator/titanium_mobile/pull/9134 6_1_X: https://github.com/appcelerator/titanium_mobile/issues/9135 -I believe this should be backported to 6_1_X, will set up the backport once permission is granted-
  4. Lokesh Choudhary 2017-06-12

    FR passed for both master & backport PR.
  5. Lokesh Choudhary 2017-06-12

    Verified the fix with SDK 6.1.1.v20170612141743. Waiting for master SDK from jenkins to close.
  6. Lokesh Choudhary 2017-06-13

    Verified the fix with SDK 6.2.0.v20170613091505. Closing. Studio Ver: 4.9.0.201705302345 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.3 Appc NPM: 4.2.9 Appc CLI: 6.2.2 Ti CLI Ver: 5.0.14 Alloy Ver: 1.9.11 Node Ver: 6.10.1 Java Ver: 1.8.0_101 Devices: ⇨ google Nexus 5 --- Android 6.0.1 ⇨ google Pixel --- Android 7.1.1 Emulator: Android 4.4.2

JSON Source