Reputation: 757
My app crashes when I open the in-app developer menu. I don't know the exact name but below is menu upon opening which the app crashes.
android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@388d962 -- permission denied for window type 2003
09-18 17:45:29.358 6982 6982 E AndroidRuntime: FATAL EXCEPTION: main
09-18 17:45:29.358 6982 6982 E AndroidRuntime: Process: com.numu.app, PID: 6982
09-18 17:45:29.358 6982 6982 E AndroidRuntime: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@388d962 -- permission denied for window type 2003
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl.setView(ViewRootImpl.java:815)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.app.Dialog.show(Dialog.java:330)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at com.facebook.react.devsupport.DevSupportManagerImpl.showDevOptionsDialog(DevSupportManagerImpl.java:482)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.showDevOptionsDialog(ReactInstanceManager.java:663)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate.onKeyUp(ReactActivityDelegate.java:166)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at com.facebook.react.ReactActivity.onKeyUp(ReactActivity.java:82)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.KeyEvent.dispatch(KeyEvent.java:2712)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.app.Activity.dispatchKeyEvent(Activity.java:3280)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:352)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4768)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4640)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4175)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4228)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4194)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4321)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4202)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4378)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4175)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4228)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4194)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4202)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4175)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4228)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4194)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4354)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4515)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2465)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2028)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2019)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2442)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.os.MessageQueue.nativePollOnce(Native Method)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.os.MessageQueue.next(MessageQueue.java:325)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.os.Looper.loop(Looper.java:142)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6798)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
09-18 17:45:29.358 6982 6982 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
09-18 17:45:29.374 4106 9992 W ActivityManager: Force finishing activity com.numu.app/.MainActivity
09-18 17:45:29.494 536 9478 E [email protected]_lock: Release wakelock is released
09-18 17:45:29.877 4106 4199 W ActivityManager: Activity pause timeout for ActivityRecord{ffed9d5 u0 com.numu.app/.MainActivity t3548 f}
09-18 17:45:29.882 560 560 E ANDR-PERF-MPCTL: hint lookup failed
09-18 17:45:29.926 4106 4199 W BroadcastQueue: Background execution not allowed: receiving Intent { act=org.codeaurora.action.stk.idle_screen flg=0x10 (has extras) } to com.android.stk/.StkCmdReceiver
09-18 17:45:30.485 5966 6232 W OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
09-18 17:45:30.485 5966 6232 W OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
09-18 17:45:40.410 4106 4199 W ActivityManager: Activity destroy timeout for ActivityRecord{ffed9d5 u0 com.numu.app/.MainActivity t3548 f}
I get these logs by running: adb logcat app-name *:W.
I have seen that this issue mostly occurs on Oreo devices with RN version 48 or greater. There are multiple solutions online that include adding native Java code. But I can't understand them properly and none of them have worked for me so far. Below are some links I have followed;
Upvotes: 0
Views: 1070
Reputation: 3904
Quoting a Github answer here:
https://github.com/facebook/react-native/issues/4043
I found a workaround here: http://stackoverflow.com/questions/32061934/permission-from-manifest-doesnt-work-in-android-6
add this to your MainActivity and call it in your onCreate or something. It will show a screen where you can activate the permission.
private static final int OVERLAY_PERMISSION_REQUEST_CODE = 2;
@TargetApi(Build.VERSION_CODES.M)
private void _askForOverlayPermission() {
if (!BuildConfig.DEBUG || android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return;
}
if (!Settings.canDrawOverlays(this)) {
Intent settingsIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(settingsIntent, OVERLAY_PERMISSION_REQUEST_CODE);
}
}
There is probably a way of implementing the dev menu that doesn't need this SystemAlertWindow though.
Upvotes: 0