Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27232] Android: Setting Window "barColor" while using a theme without an ActionBar/TitleBar will cause a crash as of 8.1.0

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-07-13T05:31:59.000+0000
Affected Version/sRelease 8.1.0
Fix Version/sRelease 8.1.0
ComponentsAndroid
Labelsandorid, engSchedule, regression, title, window
ReporterAndreas Pingas
AssigneeYordan Banev
Created2019-07-10T09:21:48.000+0000
Updated2019-07-13T05:31:59.000+0000

Description

*Summary:* Setting Ti.UI.Window property "barColor" if it's using a theme without an ActionBar will cause a crash as of Titanium 8.1.0. Note that this bug was never in a release version. It was caught before release. *Steps to reproduce:*

Set up a Classic project to build with Titanium 8.1.0.

Copy the below code to your "app.js".

Build and run on Android.

var window = Ti.UI.createWindow({
	barColor: "blue",
	theme: "Theme.AppCompat.NoTitleBar",
});
window.add(Ti.UI.createLabel({ text: "Window Title Test" }));
window.open();
*Result:* App crashes on startup and the following exception gets logged...
[ERROR] :  TiExceptionHandler: (main) [1,6371] Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setBackgroundDrawable(android.graphics.drawable.Drawable)' on a null object reference
[ERROR] :  TiExceptionHandler:
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:313)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:57)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:578)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:726)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:47)
[ERROR] :  TiExceptionHandler:     android.app.Activity.performCreate(Activity.java:6975)
---- *Use-case:* This issue is more likely to happen in apps that use theme/style XML file applied globally to the app. Like the one below supplied by [~andreas.pingas].
<style name="FullScreen" parent="@style/Theme.AppCompat.Light">
	<item name="android:soundEffectsEnabled">false</item>
	<item name="colorPrimaryDark">#000000</item>
	<item name="colorPrimary">#EF4938</item>
	<item name="colorAccent">#FFFFFF</item>
	<item name="colorControlNormal">#EF4938</item>
	<item name="colorControlActivated">#2EA1FC</item>
	<item name="colorControlHighlight">#F26D60</item>
	<item name="colorSwitchThumbNormal">#FFFFFF</item>  
	<item name="android:colorButtonNormal">#00BCFF</item>
	<item name="android:colorEdgeEffect">#EF4938</item>
	<item name="android:navigationBarColor">#000000</item>
	<item name="windowNoTitle">true</item>
	<item name="windowActionBar">false</item>
</style>
var win = Titanium.UI.createWindow({
     barColor:’#FFF’
     theme:'FullScreen'
});
win.open();

Comments

  1. Rakhi Mitro 2019-07-10

    [~andreas.pingas], Thanks for sharing with us. Can you please test this also in SDK 8.0.2.GA and let us know the results.
  2. Yordan Banev 2019-07-10

    I tried the sample against 8.0.2.GA. It does not crash there. Confirmed as a regression and I am on it. PR (master): https://github.com/appcelerator/titanium_mobile/pull/11041
  3. Yordan Banev 2019-07-11

    PR (8_1_X): https://github.com/appcelerator/titanium_mobile/pull/11043
  4. Samir Mohammed 2019-07-11

    FR Passed, waiting on Jenkins build.
  5. Christopher Williams 2019-07-12

    Merged to 8_1_X, waiting on full build to merge master PR...
  6. Christopher Williams 2019-07-12

    merged to master
  7. Keerthi Mahalingam 2019-07-13

    Verified the fix on sdk 8.2.0.v20190712143331 and 8.1.0.v20190712141959.No crashing happens. works as expected. Operating System Name = Mac OS X Version = 10.14.5 Architecture = 64bit # CPUs = 12 Memory = 17179869184 Node.js Node.js Version = 10.13.0 npm Version = 6.4.1 Titanium CLI CLI Version = 5.2.1 Titanium SDK SDK Version = 8.2.0.v20190712143331 and 8.1.0.v20190712141959 CLI =7.1.0-master.24 Device =samsung s5 android 6 Emulator =pixel android 9

JSON Source