Skip to content

[Bug] App Crashes When Deleting a Habit on Android 12Β #343

Description

@runnnnnner200

✍️ Describe the bug

Deleting any habit causes the app to crash on Android 12.

πŸ’£ Steps to reproduce

  • Delete any habit.
  • The app crashes.

πŸ”§ Expected behavior

The habit should be deleted without crashing the app.

πŸ“· Screenshots

App.Crashes.When.Deleting.a.Habit.on.Android.12.mp4

πŸ“± Tech info

  • Device: generic_x86_64 (Android Studio x86 emulator)
  • OS: Android 12
  • App Version: 4.0.0

πŸ“„ Additional context

Crash Log

--------- beginning of crash  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: FATAL EXCEPTION: main  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: Process: rocks.poopjournal.todont, PID: 4775  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: java.lang.IllegalArgumentException: rocks.poopjournal.todont: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.app.PendingIntent.checkFlags(PendingIntent.java:375)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at rocks.poopjournal.todont.utils.HabitsBottomSheetDialog.deleteAlarm(HabitsBottomSheetDialog.kt:284)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at rocks.poopjournal.todont.utils.HabitsBottomSheetDialog._init_$lambda$7(HabitsBottomSheetDialog.kt:142)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at rocks.poopjournal.todont.utils.HabitsBottomSheetDialog.$r8$lambda$NtGMwMfakvBKiGJqSn24wOOJK3E(Unknown Source:0)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at rocks.poopjournal.todont.utils.HabitsBottomSheetDialog$$ExternalSyntheticLambda5.onClick(D8$$SyntheticClass:0)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.view.View.performClick(View.java:7441)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.view.View.performClickInternal(View.java:7418)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.view.View.access$3700(View.java:835)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.view.View$PerformClick.run(View.java:28676)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:938)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:201)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:288)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7839)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)  
03-07 10:29:21.888  4775  4775 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)  

Suggested Fix
Add PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_MUTABLE when creating a PendingIntent in deleteAlarm method to comply with Android 12+ security requirements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions