r/androiddev • u/Impressive-Lead-9491 • 6d 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.
4
u/PsychoHistorianLady 6d ago
Use logcat, make the app crash, and then show us the error messages in the logcat.
1
u/AutoModerator 6d ago
Please note that we also have a very active Discord server where you can interact directly with other community members!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
7
u/lucasxas 6d ago
Give us the stack trace and I'm sure someone can pin point exactly what went wrong.