-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView #32
Comments
I'm having the same problem over here, I tried the solution that you suggested but it didn't work. Did you find something else? Any help would be great :) |
Hi, if someone else have troubles with this maybe my experience help. I tried a lot of things, and nothing worked until I found this steps for generating a release APK on React Native official documentation: https://facebook.github.io/react-native/docs/signed-apk-android.html I followed the step by step and tested the APK on my phone and now everything is working. I really don't understand why using './gradlew assembleRelease' and generating the signed APK with the Android Studio didn't work with the splash screen but with this other way of generating the APK worked perfectly. I hope it helps. |
I'm having the same problem. v3.0.0 |
Yep - hitting this issue. Works fine in development, happens when running signed production build. "react-native-splash-screen": "^3.0.1", |
Was anyone able to determine a root cause for this? What's odd is I'm only running into this issue with an obfuscated Proguard build (+ signed w/ release key). When I set |
i'm having the same error :( |
if your method is onBackPressed, then delete the super.onBackPressed(); :D |
I'm having this issue on Android even on Debug mode. Works fine on iOS.
|
Adding this method works! @Override
protected void onPause() {
SplashScreen.hide(this);
super.onPause();
} Thanks @rmarquois. |
After 2 hours of research. I found that this error: So after I tried to run the script below, I can install the release apk on my device. |
@brunolemos I was trying to run debug from Android Studio as well! The |
Hey!
Is a PR needed? (I see there are a bunch of open PRs) Thanks! |
It works fine with @duongntb94 solution should fix above mentioned issue. |
I am getting this error as well, even after adding the onPause method. Any solution here? Using version 3.1.1 with React Native 0.55
|
@duongntb94, that worked, thanks |
@duongntb94 , This fixed it. thanks a lot. |
Tried both solutions mentioned here.
|
android app crashes everytime, tried almost everything out there on internet, nothing is wokring... :-| |
Run the app from within android studio and check and logs. See what the issue is and paste the red color issue you found, in here. Someone might be able to help |
@HishamMubarak |
I have the same problem, it caused by another package. After deleting the package, I solve it. |
Any of this solution not working for me for android "Pie" Thanks! |
Which package did you delete and in which package it happened? |
+1 |
I was getting this error when I was trying to run a production apk. It would throw onShow not on startup. This error is thrown when something goes wrong within your application. For me I never asked for the fine location permission and when trying to access the user's location the app would crash. I would suggest using Logcat in the Android Studio terminal and look around for errors. It's usually above the splash screen error. |
In addition to @duongntb94 solution I think this answer on StackOverflow will be useful :) Looks like a proper way to do it automatically rather than manually. Also, you can look into a comment in |
I tried all the methods mentioned here added onPause() , executed the following command
still getting the same error.
Am on 3.1.1 version. Anyone else faced this problem and resolved by any other methods? |
Updated to 3.2.0 fixed the issue for me. |
make sure that you close the metro bundler and run it again, if you've been working on two react native projects you may have left metro bundler of some other package running. this is what happened to me. |
I tried all the above answers, none of them worked for me. I am using RN 0.59.3 and Splash Screen 3.2.0. Can anyone help? Thanks in advance |
The way I got around this issue is by not calling intent within a dialog. Below is one approach. @OverRide public void onClick(DialogInterface dialog, int which) { checkvariable= true; getActivity().finish(); } |
Hi,
I assume the error occurs immediately your snackbar shows. If that is the case, I suggest that you should not iniate the startActivity within the snack bar.
Since you have invoked, finish() in the snackbar, I suggest you move the startActivity method to onStop() method
Regards,
D.O.
…________________________________
From: NoxDRaz <[email protected]>
Sent: Wednesday, May 20, 2020 11:58 AM
To: crazycodeboy/react-native-splash-screen <[email protected]>
Cc: onyand <[email protected]>; Comment <[email protected]>
Subject: Re: [crazycodeboy/react-native-splash-screen] MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView (#32)
I am facing a similar issue.
Here is the error: https://i.stack.imgur.com/oTbXR.png<url>
And my code: `//Google Sign In
@OverRide<https://github.com/override>
protected void onActivityResult(int requestCode, int resultCode, @nullable<https://github.com/nullable> Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == GOOGLE_SIGN_IN_KEY) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
try {
GoogleSignInAccount account = task.getResult(ApiException.class);
firebaseAuthWithGoogle(account);
} catch (ApiException e) {
if (e.getStatusCode() == 12500) {
Snackbar.make(findViewById(android.R.id.content), "Sign In Error! Update Google Play Service.", Snackbar.LENGTH_LONG).show();
}
}
}
}
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
firebaseAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener() {
@OverRide<https://github.com/override>
public void onComplete(@nonnull<https://github.com/nonnull> Task task) {
if (task.isSuccessful()) {
FirebaseUser user = firebaseAuth.getCurrentUser();
showGoogleSignUpDialog();
storeUserInfo(user.getPhotoUrl().toString(), user.getUid(), user.getDisplayName(), user.getEmail());
} else {
Snackbar.make(findViewById(android.R.id.content), "Sign In Failed!", Snackbar.LENGTH_LONG).show();
}
}
});
}
private void storeUserInfo(final String stringUserImage, final String stringUserID, final String stringName, final String stringEmail) {
FirebaseUser user = firebaseAuth.getCurrentUser();
UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
.setDisplayName(stringName)
.setPhotoUri(Uri.parse(stringUserImage))
.build();
user.updateProfile(profileUpdates)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@OverRide
public void onComplete(@nonnull Task<Void> task) {
if (task.isSuccessful()) {
firebaseFirestore.collection("UserData").document(stringUserID).get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@OverRide
public void onSuccess(DocumentSnapshot documentSnapshot) {
if (documentSnapshot.getData() != null && documentSnapshot.getData().size() > 0) {
Snackbar.make(findViewById(android.R.id.content), "Welcome back!", Snackbar.LENGTH_LONG).show();
startActivity(new Intent(ActivityLogin.this, ActivityHome.class));
finish();
} else {
createUserData(stringUserID, stringUserImage, stringName, stringEmail);
}
}
});
}
}
});
}
private void createUserData(String stringUserID, String stringUserImage, String stringName, String stringEmail) {
final Map<String, Object> userDataMap = new HashMap<>();
userDataMap.put("userName", stringName);
userDataMap.put("userImage", stringUserImage);
userDataMap.put("userID", stringUserID);
userDataMap.put("userPoints", 100);
userDataMap.put("userVerified", true);
userDataMap.put("userEmail", stringEmail);
userDataMap.put("timestamp", FieldValue.serverTimestamp());
firebaseFirestore.collection("UserData").document(stringUserID).set(userDataMap)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@OverRide
public void onSuccess(Void aVoid) {
new Handler().postDelayed(new Runnable() {
@OverRide
public void run() {
alertGoogleSignIn.dismiss();
Snackbar.make(findViewById(android.R.id.content), "Welcome!", Snackbar.LENGTH_LONG).show();
startActivity(new Intent(ActivityLogin.this, ActivityHome.class).putExtra("canShowCoinCredit", true));
finish();
}
}, 3000);
}
});
}
private void showGoogleSignUpDialog() {
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Signing in");
alert.setMessage("Please hold on while we process...");
alert.setCancelable(false);
alertGoogleSignIn = alert.create();
alertGoogleSignIn.show();
}`
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#32 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADZYSRTAYKLXH467OT3RMDTRSOLSJANCNFSM4DA53D3A>.
|
I don't understand. Please see my problem here: https://stackoverflow.com/questions/61908287/startup-activitylogin-has-leaked-window-decorview3a9e526activitylogin-that-wa |
I have responded against the stackoverflow link you have shared
…________________________________
From: NoxDRaz <[email protected]>
Sent: Wednesday, May 20, 2020 2:16 PM
To: crazycodeboy/react-native-splash-screen <[email protected]>
Cc: onyand <[email protected]>; Comment <[email protected]>
Subject: Re: [crazycodeboy/react-native-splash-screen] MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView (#32)
Hi, I assume the error occurs immediately your snackbar shows. If that is the case, I suggest that you should not iniate the startActivity within the snack bar. Since you have invoked, finish() in the snackbar, I suggest you move the startActivity method to onStop() method Regards, D.O.
…
________________________________ From: NoxDRaz [email protected]<mailto:[email protected]> Sent: Wednesday, May 20, 2020 11:58 AM To: crazycodeboy/react-native-splash-screen [email protected]<mailto:[email protected]> Cc: onyand [email protected]<mailto:[email protected]>; Comment [email protected]<mailto:[email protected]> Subject: Re: [crazycodeboy/react-native-splash-screen] MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView (#32<#32>) I am facing a similar issue. Here is the error: https://i.stack.imgur.com/oTbXR.png And my code: //Google Sign In @OverRide<https://github.com/override> protected void onActivityResult(int requestCode, int resultCode, @nullable<https://github.com/nullable> Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == GOOGLE_SIGN_IN_KEY) { Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); try { GoogleSignInAccount account = task.getResult(ApiException.class); firebaseAuthWithGoogle(account); } catch (ApiException e) { if (e.getStatusCode() == 12500) { Snackbar.make(findViewById(android.R.id.content), "Sign In Error! Update Google Play Service.", Snackbar.LENGTH_LONG).show(); } } } } private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); firebaseAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener() { @OverRide<https://github.com/override> public void onComplete(@nonnull<https://github.com/nonnull> Task task) { if (task.isSuccessful()) { FirebaseUser user = firebaseAuth.getCurrentUser(); showGoogleSignUpDialog(); storeUserInfo(user.getPhotoUrl().toString(), user.getUid(), user.getDisplayName(), user.getEmail()); } else { Snackbar.make(findViewById(android.R.id.content), "Sign In Failed!", Snackbar.LENGTH_LONG).show(); } } }); } private void storeUserInfo(final String stringUserImage, final String stringUserID, final String stringName, final String stringEmail) { FirebaseUser user = firebaseAuth.getCurrentUser(); UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder() .setDisplayName(stringName) .setPhotoUri(Uri.parse(stringUserImage)) .build(); user.updateProfile(profileUpdates) .addOnCompleteListener(new OnCompleteListener<Void>() { @OverRide public void onComplete(@nonnull Task<Void> task) { if (task.isSuccessful()) { firebaseFirestore.collection("UserData").document(stringUserID).get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() { @OverRide public void onSuccess(DocumentSnapshot documentSnapshot) { if (documentSnapshot.getData() != null && documentSnapshot.getData().size() > 0) { Snackbar.make(findViewById(android.R.id.content), "Welcome back!", Snackbar.LENGTH_LONG).show(); startActivity(new Intent(ActivityLogin.this, ActivityHome.class)); finish(); } else { createUserData(stringUserID, stringUserImage, stringName, stringEmail); } } }); } } }); } private void createUserData(String stringUserID, String stringUserImage, String stringName, String stringEmail) { final Map<String, Object> userDataMap = new HashMap<>(); userDataMap.put("userName", stringName); userDataMap.put("userImage", stringUserImage); userDataMap.put("userID", stringUserID); userDataMap.put("userPoints", 100); userDataMap.put("userVerified", true); userDataMap.put("userEmail", stringEmail); userDataMap.put("timestamp", FieldValue.serverTimestamp()); firebaseFirestore.collection("UserData").document(stringUserID).set(userDataMap) .addOnSuccessListener(new OnSuccessListener<Void>() { @OverRide public void onSuccess(Void aVoid) { new Handler().postDelayed(new Runnable() { @OverRide public void run() { alertGoogleSignIn.dismiss(); Snackbar.make(findViewById(android.R.id.content), "Welcome!", Snackbar.LENGTH_LONG).show(); startActivity(new Intent(ActivityLogin.this, ActivityHome.class).putExtra("canShowCoinCredit", true)); finish(); } }, 3000); } }); } private void showGoogleSignUpDialog() { final AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Signing in"); alert.setMessage("Please hold on while we process..."); alert.setCancelable(false); alertGoogleSignIn = alert.create(); alertGoogleSignIn.show(); } — You are receiving this because you commented. Reply to this email directly, view it on GitHub<#32 (comment)<#32 (comment)>>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZYSRTAYKLXH467OT3RMDTRSOLSJANCNFSM4DA53D3A.
I don't understand. Please see my problem here: https://stackoverflow.com/questions/61908287/startup-activitylogin-has-leaked-window-decorview3a9e526activitylogin-that-wa
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#32 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADZYSRV6GZGSNGAO5PVR5S3RSO32NANCNFSM4DA53D3A>.
|
Yes I replied there. But I am not getting that error in the logcat anymore. |
thanks. It helped a lot. |
Thanks. worked for me! |
I faced to this similar issue: |
I have no idea if this is right, or if it will help someone else, but I was struggling with this for hours, and ultimately what seemed to fix it for me was adding the |
Hello.
When I start my app compiled in release mode I've got this error :
I fix it with the following code in the
MainActivity.java
:I can't confirm that it's the best solution but it works !
The text was updated successfully, but these errors were encountered: