react-native: [Android - Crash] Opening dev menu crashes the app
Shaking my phone (Nexus 5, API level 23) in dev mode crashes the app with the following stack trace:
11-10 16:35:03.453 25354-25354/com.truckfly.truckfly W/System.err: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@5d992cf -- permission denied for this window type
11-10 16:35:03.475 25354-25354/com.truckfly.truckfly W/System.err: at android.view.ViewRootImpl.setView(ViewRootImpl.java:591)
11-10 16:35:03.475 25354-25354/com.truckfly.truckfly W/System.err: at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:310)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at android.app.Dialog.show(Dialog.java:319)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at com.facebook.react.devsupport.DevSupportManager.showDevOptionsDialog(DevSupportManager.java:336)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at com.facebook.react.devsupport.DevSupportManager$1.onShake(DevSupportManager.java:123)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at com.facebook.react.common.ShakeDetector.maybeDispatchShake(ShakeDetector.java:118)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at com.facebook.react.common.ShakeDetector.onSensorChanged(ShakeDetector.java:92)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:481)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at android.os.MessageQueue.nativePollOnce(Native Method)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at android.os.MessageQueue.next(MessageQueue.java:323)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at android.os.Looper.loop(Looper.java:135)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at java.lang.reflect.Method.invoke(Native Method)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-10 16:35:03.476 25354-25354/com.truckfly.truckfly W/FlurryAgent: Error logged: uncaught
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: FATAL EXCEPTION: main
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: Process: com.truckfly.truckfly, PID: 25354
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@5d992cf -- permission denied for this window type
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at android.view.ViewRootImpl.setView(ViewRootImpl.java:591)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:310)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at android.app.Dialog.show(Dialog.java:319)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at com.facebook.react.devsupport.DevSupportManager.showDevOptionsDialog(DevSupportManager.java:336)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at com.facebook.react.devsupport.DevSupportManager$1.onShake(DevSupportManager.java:123)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at com.facebook.react.common.ShakeDetector.maybeDispatchShake(ShakeDetector.java:118)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at com.facebook.react.common.ShakeDetector.onSensorChanged(ShakeDetector.java:92)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:481)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at android.os.MessageQueue.nativePollOnce(Native Method)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at android.os.MessageQueue.next(MessageQueue.java:323)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-10 16:35:03.477 25354-25354/com.truckfly.truckfly E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-10 16:35:03.478 809-5688/? W/ActivityManager: Force finishing activity com.truckfly.truckfly/.MainActivity
I’m using RN 0.14.2
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 2
- Comments: 24 (13 by maintainers)
Same error running on emulator running API 26 after running
react-native run-android
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.There is probably a way of implementing the dev menu that doesn’t need this SystemAlertWindow though.
You have to make sure this is in your AndroidManifest.xml
Still happening to me. I am pretty sure that using a compile and build tools version of 25 should fix this, however multiple dependencies are now using compile 26 or 27, which means I am stuck with them. I decided to test in debug without Android 8 and release with it
Still happening!
Also getting this with similar setup to @Darex1991. Error message is for window type 2003.
android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@163bc63 -- permission denied for window type 2003
Also, it only happens in Debug. Android 8.0 emulators run the App fine when working in Release mode.