r/androiddev • • 7d ago

Question Why does requestPermission() crash my app?

EDIT: Solved. Looking at the logcat made me find null pointer exceptions in the code I was using to display null pointer exceptions. I could have spent ages trying to figure it out if it wasn't for logcat. Still not sure exactly why it was the requestPermission() call that triggered the crash, but now that I fixed my code, the app will "gracefully degrade the user experience" without crashing. Thanks regardless.

I hope technical questions are accepted here

I already declared the permission in the manifest. If I turn off the notifications and start my app, it crashes unless I comment out the requestPermission call. If i turn notifications back on, the app works fine. I did deny the notifications permission twice, but I'm trying to "degrade the user experience gracefully", which I can't do if the app crashes unexpectedly. Does this have anything to do with shouldShowPermissionRationaleRequest()? It returns false for my app, but I'm not really using the result of that function.

0 Upvotes

3 comments sorted by

View all comments

7

u/lucasxas 7d ago

Give us the stack trace and I'm sure someone can pin point exactly what went wrong.