question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView

See original GitHub issue

Hello.

When I start my app compiled in release mode I’ve got this error :

Activity com.myapp.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{415ceea8 V.E..... R.....I. 0,0-1024,552} that was originally added here
E/WindowManager(25826): android.view.WindowLeaked: Activity com.myapp.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{415ceea8 V.E..... R.....I. 0,0-1024,552} that was originally added here
E/WindowManager(25826): 	at android.view.ViewRootImpl.<init>(ViewRootImpl.java:409)
E/WindowManager(25826): 	at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:218)
E/WindowManager(25826): 	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
E/WindowManager(25826): 	at android.app.Dialog.show(Dialog.java:281)
E/WindowManager(25826): 	at com.cboy.rn.splashscreen.SplashScreen$1.run(SplashScreen.java:32)
E/WindowManager(25826): 	at android.app.Activity.runOnUiThread(Activity.java:4662)
E/WindowManager(25826): 	at com.cboy.rn.splashscreen.SplashScreen.show(SplashScreen.java:22)
E/WindowManager(25826): 	at com.cboy.rn.splashscreen.SplashScreen.show(SplashScreen.java:42)
E/WindowManager(25826): 	at com.myapp.MainActivity.onCreate(MainActivity.java:11)
E/WindowManager(25826): 	at android.app.Activity.performCreate(Activity.java:5122)
E/WindowManager(25826): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
E/WindowManager(25826): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
E/WindowManager(25826): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
E/WindowManager(25826): 	at android.app.ActivityThread.access$600(ActivityThread.java:156)
E/WindowManager(25826): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
E/WindowManager(25826): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/WindowManager(25826): 	at android.os.Looper.loop(Looper.java:153)
E/WindowManager(25826): 	at android.app.ActivityThread.main(ActivityThread.java:5299)
E/WindowManager(25826): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/WindowManager(25826): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/WindowManager(25826): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
E/WindowManager(25826): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
E/WindowManager(25826): 	at dalvik.system.NativeStart.main(Native Method)

I fix it with the following code in the MainActivity.java :

    @Override
    protected void onCreate(Bundle savedInstanceState) {
      SplashScreen.show(this);
      super.onCreate(savedInstanceState);
    }

    // my new code here
    @Override
    protected void onPause() {
      SplashScreen.hide(this);
      super.onPause();
    }

I can’t confirm that it’s the best solution but it works !

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:49
  • Comments:39

github_iconTop GitHub Comments

14reactions
duongntb94commented, Mar 12, 2018

After 2 hours of research. Above the problem : android.view.WindowLeaked: Activity com.xxx.MainActivity has leaked window com.android.internal.policy.PhoneWindow$DecorView{b2059e6 V.E...... R.....ID 0,0-2048,1536} that was originally added here

I found that this error: FATAL EXCEPTION: Thread-170 Process: com.xxx, PID: 1734 java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server. at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method) at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:216) at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:33) at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:234) at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1137) at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:113) at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:944) at java.lang.Thread.run(Thread.java:818)

So after I tried to run the script below, I can install the release apk on my device. mkdir android/app/src/main/assets react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

13reactions
butchmarshallcommented, Nov 5, 2017

Yep - hitting this issue. Works fine in development, happens when running signed production build.

“react-native-splash-screen”: “^3.0.1”,

Read more comments on GitHub >

github_iconTop Results From Across the Web

android activity has leaked window com.android.internal ...
android activity has leaked window com.android.internal.policy.impl.phonewindow$decorview Issue ... I am working with Android application to show ...
Read more >
Activity has leaked window com.android.internal.policy.impl ...
I am receiving the above error when launching my application in version 3.1 in my tablet. It works fine from 2.1 to 2.3...
Read more >
app.MainActivity has leaked window com.android.internal.policy
How to solve :Activity com.app.moko. MainActivity has leaked window com.android. internal. policy. impl.PhoneWindow--------that error appear ...
Read more >
Activity has leaked window - Mobikul
Error: E/WindowManager: android.view.WindowLeaked: Activity com.example.android has leaked window. com.android.internal.policy.
Read more >
Android.View.Windowleaked(Progress Dialog Is Leaking To ...
myP has leaked window com.android.internal.policy.impl. which causes the Activity ... PhoneWindowDecorView@43d3e558 That was originally added here Solution: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found