Closed itlancer closed 1 year ago
Issue still exists with latest AIR 50.2.3.4:
D/StrictMode: StrictMode policy violation: android.os.strictmode.IncorrectContextUseViolation: WindowManager should be accessed from Activity or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle), which are adjusted to the configuration and visual bounds of an area on screen.
at android.os.StrictMode.onIncorrectContextUsed(StrictMode.java:2260)
at android.app.ContextImpl.getSystemService(ContextImpl.java:2116)
at android.content.ContextWrapper.getSystemService(ContextWrapper.java:900)
at com.adobe.air.SystemCapabilities.GetRealScreenHRes(SystemCapabilities.java:36)
Caused by: java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:androidx.multidex.MultiDexApplication@c3261e9
at android.app.ContextImpl.getSystemService(ContextImpl.java:2115)
at android.content.ContextWrapper.getSystemService(ContextWrapper.java:900)
at com.adobe.air.SystemCapabilities.GetRealScreenHRes(SystemCapabilities.java:36)
Thanks -> looks like we are picking up the application context rather than the activity, within these Capabilities calls. And a few other areas as well..
Fixed with latest AIR 50.2.3.5. Thank you!
Problem Description
Enabling
StrictMode
(via native extension) with Android 11+ causeIncorrectContextUseViolation
IllegalAccessException
from AIR. Seems AIR for Android not properly updated for Android 11+. We useStrictMode
to debug performance/compatibility issues with complex applications for Android.It has been tested with latest AIR 33.1.1.743 with multiple Android 11 and 12 devices. Same problem in all cases. Even with Android emulator.
Related links: https://github.com/AppsFlyerSDK/appsflyer-android-sdk/issues/17 https://github.com/google/ExoPlayer/issues/8246
Steps to Reproduce
Create Java native extension with code below in some function:
It will enable
StrictMode
to debug any Android performance/compatibility issues and warnings. Then launch AIR application that calling this function from native extension somewhere just after start. For example, just afterEvent.ADDED_TO_STAGE
event fired.Actual Result: Application crash (because of
.penaltyDeath()
) with ADB log:Expected Result:
StrictMode
will be enabled for Android and nothing more happens.Known Workarounds
none