MaikuB / flutter_local_notifications

A Flutter plugin for displaying local notifications on Android, iOS, macOS and Linux
2.45k stars 1.4k forks source link

Crashes Android apps published to the Play Store #452

Closed urmilshroff closed 4 years ago

urmilshroff commented 4 years ago

Describe the bug Android apps published to the Google Play Store that utilize this plugin's features simply crash when trying to create a notification. If I build the same app in debug or release mode and test it on a device, it works absolutely fine. But when I create the appbundle and publish it to the Play Store, then download the app from there, it will crash when trying to set a notification. This has happened to three different apps of mine, all of which use this plugin, so I've come to the conclusion that it is a problem with the plugin.

To Reproduce

  1. Create an app using this plugin's features
  2. Test on a device in debug or release mode, it'll work fine
  3. Build the appbundle and publish to Play Store
  4. Download from the Play Store and the same app will crash when setting a notification.

Sample code to reproduce the problem Goalkeeper GitHub Goalkeeper Google Play

Fliver Rider GitHub Fliver Rider Google Play

Fliver Driver GitHub Fliver Driver Google Play (Crashes on launch as the notification is created in main() itself)

MaikuB commented 4 years ago

It looks like none of your apps included a Proguard rules file. Can you try adding one (see readme for more info) and see how that goes?

urmilshroff commented 4 years ago

It looks like none of your apps included a Proguard rules file. Can you try adding one (see readme for more info) and see how that goes?

The latest documentation for Building an Android App for Release talks about R8 and how it automatically optimizes the code. There's no mention of using ProGuard anymore, so should I still use it?

MaikuB commented 4 years ago

Yes https://developer.android.com/studio/build/shrink-code

urmilshroff commented 4 years ago

Looks like I managed to fix it by using the proguard-rules.pro from your example app. Now let's hope that the apps work when the updates go live on the Play Store. Thanks a lot!

chrystoffer commented 4 years ago

I had the same problem and creating proguard-rules.pro solved my problem tks

MaikuB commented 4 years ago

@urmilshroff glad to hear it. In case you haven't already, it's worth creating other tracks in the Google Play store for testing. Flutter's documentation did use to mention have the rules file but I believe that's been removed because there tooling will now generate one when creating a new app. From memory, that didn't use to be the case

urmilshroff commented 4 years ago

@urmilshroff glad to hear it. In case you haven't already, it's worth creating other tracks in the Google Play store for testing. Flutter's documentation did use to mention have the rules file but I believe that's been removed because there tooling will now generate one when creating a new app. From memory, that didn't use to be the case

Yes, I think I remember some proguard-rules.pro files being generate in projects when I was initially learning Flutter. Looks like they've stopped it now.

I didn't consider launching my apps as beta because the release builds were working perfectly on my devices, so didn't think publishing would cause any issues. But I'll definitely keep that in mind from now on😅

Anyway, all my apps are working fine now after adding the proguard-rules.pro, so cheers!🍻

ooooconsumer commented 4 years ago

I think You should put this info somewhere in the README :)

MaikuB commented 4 years ago

I did under the Android integration guide

MaikuB commented 4 years ago

If you feel there's something else, you can submit a pull request