android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

JIRA | Elliot Smith | 2 years ago
  1. 0

    Impacted Cases ============== Developers attempting to make use of the presentation API. Reproduce Test Steps ==================== 1. Unzip the attached file 2. Package the unzipped application using make_apk.py: {code} python make_apk.py --manifest=app/manifest.json --package=foo.elliot --name=secondscreen --enable-remote-debugging {code} 3. Install on Android device. 4. Put wireless adapter into TV, turn on correct HDMI channel etc. 5. Connect Android device to wireless display adapter. 6. Start application; second screen is shown to be connected. I also see the tablet's screen displayed on the second screen, as expected. 7. Attempt to open the image-display.html page on the second screen by tapping an image on the tablet's screen. Expected Outcome ================ HTML page opens on second screen. Actual Outcome ============== Application crashes with an "Application has stopped unexpectedly" message. Test Case Source Code ===================== See attached file. Test Builds =========== N/A Issue Analysis ============== The adb logcat output around the time of the crash is as follows: {code} W/WindowManager( 558): Attempted to add window with non-application token WindowToken{427376f8 null}. Aborting. E/AndroidRuntime(13507): FATAL EXCEPTION: main E/AndroidRuntime(13507): Process: foo.elliot, PID: 13507 E/AndroidRuntime(13507): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application E/AndroidRuntime(13507): at android.view.ViewRootImpl.setView(ViewRootImpl.java:536) E/AndroidRuntime(13507): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259) E/AndroidRuntime(13507): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) E/AndroidRuntime(13507): at android.app.Dialog.show(Dialog.java:286) E/AndroidRuntime(13507): at android.app.Presentation.show(Presentation.java:235) E/AndroidRuntime(13507): at org.xwalk.core.internal.extension.api.presentation.PresentationViewJBMR1.show(PresentationViewJBMR1.java:28) E/AndroidRuntime(13507): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension.updatePresentationView(PresentationExtension.java:395) E/AndroidRuntime(13507): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension.access$1000(PresentationExtension.java:34) E/AndroidRuntime(13507): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension$2.run(PresentationExtension.java:295) E/AndroidRuntime(13507): at android.os.Handler.handleCallback(Handler.java:733) E/AndroidRuntime(13507): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime(13507): at android.os.Looper.loop(Looper.java:136) E/AndroidRuntime(13507): at android.app.ActivityThread.main(ActivityThread.java:5001) E/AndroidRuntime(13507): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(13507): at java.lang.reflect.Method.invoke(Method.java:515) E/AndroidRuntime(13507): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) E/AndroidRuntime(13507): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) E/AndroidRuntime(13507): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( 558): Force finishing activity foo.elliot/.ElliotActivity D/dalvikvm(13507): GC_CONCURRENT freed 322K, 4% free 9437K/9796K, paused 1ms+2ms, total 32ms W/ActivityManager( 558): Activity pause timeout for ActivityRecord{42250470 u0 foo.elliot/.ElliotActivity t75 f} I/Process (13507): Sending signal. PID: 13507 SIG: 9 I/ActivityManager( 558): Process foo.elliot (pid 13507) has died. I/WindowState( 558): WIN DEATH: Window{42ce6df0 u0 SurfaceView} I/WindowState( 558): WIN DEATH: Window{42aeaa98 u0 foo.elliot/foo.elliot.ElliotActivity} {code}

    JIRA | 2 years ago | Elliot Smith
    android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
  2. 0

    Impacted Cases ============== Developers attempting to make use of the presentation API. Reproduce Test Steps ==================== 1. Unzip the attached file 2. Package the unzipped application using make_apk.py: {code} python make_apk.py --manifest=app/manifest.json --package=foo.elliot --name=secondscreen --enable-remote-debugging {code} 3. Install on Android device. 4. Put wireless adapter into TV, turn on correct HDMI channel etc. 5. Connect Android device to wireless display adapter. 6. Start application; second screen is shown to be connected. I also see the tablet's screen displayed on the second screen, as expected. 7. Attempt to open the image-display.html page on the second screen by tapping an image on the tablet's screen. Expected Outcome ================ HTML page opens on second screen. Actual Outcome ============== Application crashes with an "Application has stopped unexpectedly" message. Test Case Source Code ===================== See attached file. Test Builds =========== N/A Issue Analysis ============== The adb logcat output around the time of the crash is as follows: {code} W/WindowManager( 558): Attempted to add window with non-application token WindowToken{427376f8 null}. Aborting. E/AndroidRuntime(13507): FATAL EXCEPTION: main E/AndroidRuntime(13507): Process: foo.elliot, PID: 13507 E/AndroidRuntime(13507): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application E/AndroidRuntime(13507): at android.view.ViewRootImpl.setView(ViewRootImpl.java:536) E/AndroidRuntime(13507): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259) E/AndroidRuntime(13507): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) E/AndroidRuntime(13507): at android.app.Dialog.show(Dialog.java:286) E/AndroidRuntime(13507): at android.app.Presentation.show(Presentation.java:235) E/AndroidRuntime(13507): at org.xwalk.core.internal.extension.api.presentation.PresentationViewJBMR1.show(PresentationViewJBMR1.java:28) E/AndroidRuntime(13507): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension.updatePresentationView(PresentationExtension.java:395) E/AndroidRuntime(13507): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension.access$1000(PresentationExtension.java:34) E/AndroidRuntime(13507): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension$2.run(PresentationExtension.java:295) E/AndroidRuntime(13507): at android.os.Handler.handleCallback(Handler.java:733) E/AndroidRuntime(13507): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime(13507): at android.os.Looper.loop(Looper.java:136) E/AndroidRuntime(13507): at android.app.ActivityThread.main(ActivityThread.java:5001) E/AndroidRuntime(13507): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(13507): at java.lang.reflect.Method.invoke(Method.java:515) E/AndroidRuntime(13507): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) E/AndroidRuntime(13507): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) E/AndroidRuntime(13507): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( 558): Force finishing activity foo.elliot/.ElliotActivity D/dalvikvm(13507): GC_CONCURRENT freed 322K, 4% free 9437K/9796K, paused 1ms+2ms, total 32ms W/ActivityManager( 558): Activity pause timeout for ActivityRecord{42250470 u0 foo.elliot/.ElliotActivity t75 f} I/Process (13507): Sending signal. PID: 13507 SIG: 9 I/ActivityManager( 558): Process foo.elliot (pid 13507) has died. I/WindowState( 558): WIN DEATH: Window{42ce6df0 u0 SurfaceView} I/WindowState( 558): WIN DEATH: Window{42aeaa98 u0 foo.elliot/foo.elliot.ElliotActivity} {code}

    JIRA | 2 years ago | Elliot Smith
    android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
  3. 0

    IMPACTED CASES: ========================================================================= Presentation Test REPRODUCE TEST STEPS: ========================================================================= Pre-condition: Turn on "Simulate secondary displays" on phone by Settings->Developer options->Simulate secondary displays 1. Download "webapi-usecase-tests-9.38.204.0-1.apk.zip"(see the url in comment). 2. Install "webapi-usecase-tests-9.38.204.0-1.apk" by: unzip webapi-usecase-tests-9.38.204.0-1.apk.zip adb install opt/webapi-usecase-tests/webapi-usecase-tests_x86.apk 3. Click the icon of the "webapi-usecase-tests" app, select "Presentation Test" TC, click "run" button. 4. Click "Request Show Presentation" button. EXPECTED OUTCOME: ========================================================================= an presention window should show on wireless display. ACTUAL OUTCOME: ========================================================================= "webapi_usecase_tests" app crashed. ISSUE ANALYSIS: ========================================================================= The logcat log as below: {code} 09-15 09:42:13.389: W/dalvikvm(7815): threadid=1: thread exiting with uncaught exception (group=0x41dc9930) 09-15 09:42:13.389: W/WindowManager(526): Attempted to add window with non-application token WindowToken{4263da70 null}. Aborting. E/AndroidRuntime(11182): FATAL EXCEPTION: main E/AndroidRuntime(11182): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application E/AndroidRuntime(11182): at android.view.ViewRootImpl.setView(ViewRootImpl.java:575) E/AndroidRuntime(11182): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:246) E/AndroidRuntime(11182): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) E/AndroidRuntime(11182): at android.app.Dialog.show(Dialog.java:281) E/AndroidRuntime(11182): at android.app.Presentation.show(Presentation.java:235) E/AndroidRuntime(11182): at org.xwalk.core.internal.extension.api.presentation.PresentationViewJBMR1.show(PresentationViewJBMR1.java:28) E/AndroidRuntime(11182): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension.updatePresentationView(PresentationExtension.java:395) E/AndroidRuntime(11182): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension.access$1000(PresentationExtension.java:34) E/AndroidRuntime(11182): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension$2.run(PresentationExtension.java:295) E/AndroidRuntime(11182): at android.os.Handler.handleCallback(Handler.java:725) E/AndroidRuntime(11182): at android.os.Handler.dispatchMessage(Handler.java:92) E/AndroidRuntime(11182): at android.os.Looper.loop(Looper.java:152) E/AndroidRuntime(11182): at android.app.ActivityThread.main(ActivityThread.java:5132) E/AndroidRuntime(11182): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(11182): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime(11182): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) E/AndroidRuntime(11182): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) E/AndroidRuntime(11182): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( 2106): Force finishing activity org.xwalk.webapi_usecase_tests/.WebapiUsecaseTestsActivity {code} Test Case Sources Code: ========================================================================= || Type || URL || | Source Code | https://github.com/crosswalk-project/crosswalk-test-suite/blob/master/usecase/webapi-usecase-tests/tests/Presentation | TEST BUILDS: ========================================================================= ||Version||Test Date|| Test Device || Result || |Canary 9.38.199.0|2014.09.09| ZTE Geek V975 (IA) | {color:green}Pass{color} | |Canary 9.38.204.0|2014.09.15| ZTE Geek V975 (IA) | {color:red}Fail{color} |

    JIRA | 2 years ago | Jingya Cao
    android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    IMPACTED CASES: ========================================================================= Presentation Test REPRODUCE TEST STEPS: ========================================================================= Pre-condition: Turn on "Simulate secondary displays" on phone by Settings->Developer options->Simulate secondary displays 1. Download "webapi-usecase-tests-9.38.204.0-1.apk.zip"(see the url in comment). 2. Install "webapi-usecase-tests-9.38.204.0-1.apk" by: unzip webapi-usecase-tests-9.38.204.0-1.apk.zip adb install opt/webapi-usecase-tests/webapi-usecase-tests_x86.apk 3. Click the icon of the "webapi-usecase-tests" app, select "Presentation Test" TC, click "run" button. 4. Click "Request Show Presentation" button. EXPECTED OUTCOME: ========================================================================= an presention window should show on wireless display. ACTUAL OUTCOME: ========================================================================= "webapi_usecase_tests" app crashed. ISSUE ANALYSIS: ========================================================================= The logcat log as below: {code} 09-15 09:42:13.389: W/dalvikvm(7815): threadid=1: thread exiting with uncaught exception (group=0x41dc9930) 09-15 09:42:13.389: W/WindowManager(526): Attempted to add window with non-application token WindowToken{4263da70 null}. Aborting. E/AndroidRuntime(11182): FATAL EXCEPTION: main E/AndroidRuntime(11182): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application E/AndroidRuntime(11182): at android.view.ViewRootImpl.setView(ViewRootImpl.java:575) E/AndroidRuntime(11182): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:246) E/AndroidRuntime(11182): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) E/AndroidRuntime(11182): at android.app.Dialog.show(Dialog.java:281) E/AndroidRuntime(11182): at android.app.Presentation.show(Presentation.java:235) E/AndroidRuntime(11182): at org.xwalk.core.internal.extension.api.presentation.PresentationViewJBMR1.show(PresentationViewJBMR1.java:28) E/AndroidRuntime(11182): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension.updatePresentationView(PresentationExtension.java:395) E/AndroidRuntime(11182): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension.access$1000(PresentationExtension.java:34) E/AndroidRuntime(11182): at org.xwalk.core.internal.extension.api.presentation.PresentationExtension$2.run(PresentationExtension.java:295) E/AndroidRuntime(11182): at android.os.Handler.handleCallback(Handler.java:725) E/AndroidRuntime(11182): at android.os.Handler.dispatchMessage(Handler.java:92) E/AndroidRuntime(11182): at android.os.Looper.loop(Looper.java:152) E/AndroidRuntime(11182): at android.app.ActivityThread.main(ActivityThread.java:5132) E/AndroidRuntime(11182): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(11182): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime(11182): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) E/AndroidRuntime(11182): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) E/AndroidRuntime(11182): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( 2106): Force finishing activity org.xwalk.webapi_usecase_tests/.WebapiUsecaseTestsActivity {code} Test Case Sources Code: ========================================================================= || Type || URL || | Source Code | https://github.com/crosswalk-project/crosswalk-test-suite/blob/master/usecase/webapi-usecase-tests/tests/Presentation | TEST BUILDS: ========================================================================= ||Version||Test Date|| Test Device || Result || |Canary 9.38.199.0|2014.09.09| ZTE Geek V975 (IA) | {color:green}Pass{color} | |Canary 9.38.204.0|2014.09.15| ZTE Geek V975 (IA) | {color:red}Fail{color} |

    JIRA | 2 years ago | Jingya Cao
    android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
  6. 0

    How to show spinning progress dialogue with using separate Async Task Class

    Stack Overflow | 3 years ago | M00N15
    java.lang.IllegalStateException: Could not execute method of the activity

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. android.view.WindowManager$BadTokenException

      Unable to add window -- token null is not for an application

      at android.view.ViewRootImpl.setView()
    2. Android Platform
      Presentation.show
      1. android.view.ViewRootImpl.setView(ViewRootImpl.java:536)
      2. android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259)
      3. android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
      4. android.app.Dialog.show(Dialog.java:286)
      5. android.app.Presentation.show(Presentation.java:235)
      5 frames
    3. org.xwalk.core
      PresentationExtension$2.run
      1. org.xwalk.core.internal.extension.api.presentation.PresentationViewJBMR1.show(PresentationViewJBMR1.java:28)
      2. org.xwalk.core.internal.extension.api.presentation.PresentationExtension.updatePresentationView(PresentationExtension.java:395)
      3. org.xwalk.core.internal.extension.api.presentation.PresentationExtension.access$1000(PresentationExtension.java:34)
      4. org.xwalk.core.internal.extension.api.presentation.PresentationExtension$2.run(PresentationExtension.java:295)
      4 frames
    4. Android Platform
      ActivityThread.main
      1. android.os.Handler.handleCallback(Handler.java:733)
      2. android.os.Handler.dispatchMessage(Handler.java:95)
      3. android.os.Looper.loop(Looper.java:136)
      4. android.app.ActivityThread.main(ActivityThread.java:5001)
      4 frames
    5. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invokeNative(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:515)
      2 frames
    6. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
      2 frames
    7. Android Platform
      NativeStart.main
      1. dalvik.system.NativeStart.main(Native Method)
      1 frame