Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26157

Android: A semi-transparent or modal Window with a fixed orientation crashes on Android 8



      An app targeting API Level 26 (aka: Android 8.0) or higher will crash with an IllegalStateException when opening a fixed orientation window (ie: portrait-only or landscape-only) using properties:

      • opacity set to any value, including 1.0
      • modal set to true
      • backgroundColor with semi-transparency such as "rgba(255,0,0,138)"

      Steps to reproduce:

      1. Create a Titanium 7.3.0 project.
      2. Build and run the below code on an Android 8 device.
      3. Note that the app crashes (or hangs) on startup and fails to display the window.
      4. Build and run on an Android 7 or older device.
      5. Note that the app runs just fine.

      var window = Ti.UI.createWindow({
      	opacity: 0.5,
      //	modal: true,
      //	backgroundColor: "rgba(0,0,255,128)",
      	orientationModes: [Ti.UI.PORTRAIT],


      • This issue only happens when targeting API Level 26+, which Titanium does by default as of v7.3.0.
      • This issue can also be reproduced by using a semitransparent backgroundColor as well.
      • You "can" use the opacity or modal property as long as you never use the orientationModes property.
      • You "can" use the orientationModes property as long as you never use the opacity or modal properties.
      • Setting the fullscreen property to true does not appear to work-around the issue as suggested by the exception message.

      Google has introduced a breaking change where you can no longer assign an orientation to a "translucent" activity window. Setting the modal and opacity properties causes Titanium to use a translucent themed activity window. Calling the Java setRequestedOrientation() method on such a window will cause the following exception to be thrown.

      java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

      Note that this is not an issue if the app targets API Level 25 or lower on an Android 8 device. But lowering the API Level is not a valid work-around since Google Play will soon reject apps which do not target Android 8.

      This issue can be seen happening to other native Android devs here...

      Google's code change that introduced this issue can be seen below. See the Java ActivityRecord.setRequestedOrientation() method.


      • If you need to use the orientationModes property, then you cannot use the modal or opacity properties.
      • If you need to use the modal or opacity properties, then you cannot use the orientationModes properties, which means the window will support all orientations.
      • No other work-around is known for the moment... other than to mock your own modal/semitransparent window using views instead.




            • Assignee:
              jquick Joshua Quick
              jquick Joshua Quick
              Gary Mathews
            • Watchers:
              0 Start watching this issue


              • Created:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  Sync status:
                  Last received:
                  Last sent:

                  Git Integration