2

Consider below crash in Firebase:

Unable to add window token android.os.BinderProxy is not valid; is your activity running? enter image description here

This crash occurs in ViewRootImpl.java. However, Firebase doesn't reference a part in my own code. How do I know where in my code this is happening?

Jim Clermonts
  • 1,694
  • 8
  • 39
  • 94
  • https://stackoverflow.com/a/10509848/8109202 – Ezra Lazuardy Feb 06 '20 at 01:35
  • Hello @EzraLazuardy I understand the problem, however the question is about where in the code it is happening since I only have the Firebase crash with no reference to my own source code. – Jim Clermonts Feb 06 '20 at 08:52
  • @JimClermonts do this in on pause() method dialog.cancel(); in every screen (Activity, Fragment, etc), And you can test this case using Developer mode => don't keep activity. enable don't keep activity feature in developer mode and open your app and change screen while dialog is open or press home button while dialog is showing you get same crash:) – hio Feb 07 '20 at 07:20

3 Answers3

-1

This is most likely happening because you are trying to show a dialog after execution of a background thread, while the Activity is being destroyed.

cinemassacres
  • 389
  • 4
  • 16
  • Maybe my question is not clear enough, I've changed it: Firebase stacktrace does not show where in the code the problem is occuring – Jim Clermonts Feb 08 '20 at 10:51
-1

do this in on pause() method dialog.cancel();

hio
  • 915
  • 8
  • 26
  • Maybe my question is not clear enough, I've changed it: Firebase stacktrace does not show where in the code the problem is occuring – Jim Clermonts Feb 08 '20 at 10:51
  • @JimClermonts but in every screen for dialog do this u may never get that type of crash i resolved using this on my same problem bro – hio Feb 10 '20 at 06:45
  • This is a huge code base. Adding this check everywhere is a cumbersome process. I was hoping there was a better solution. But I think there isn't :(. – Jim Clermonts Feb 13 '20 at 08:27
-1

before closing the dialog check below condition -

if(!isActivityFinishing()){
    dialog.dismiss();
}
Dipankar Baghel
  • 1,932
  • 2
  • 12
  • 24
  • Maybe my question is not clear enough, I've changed it: Firebase stacktrace does not show where in the code the problem is occuring – Jim Clermonts Feb 08 '20 at 10:51
  • according to stack trace you might be displaying or dismissing the dialog when activity is finished thats why stack trace showing "is your activity running?" so need to check the condition isActivityFinishing before showing or displaying the dialog. – Dipankar Baghel Feb 08 '20 at 12:34
  • This is a huge code base. Adding this check everywhere is a cumbersome process. I was hoping there was a better solution. Find the exact line of code where this is happening. – Jim Clermonts Feb 13 '20 at 08:26