New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local notifications not working at all with shrinkResources set to true #1762
Comments
Did you follow the steps referenced in the second paragraph of https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications#release-build-configuration? You don't mention it in your post so I assume that it hasn't been done as the paragraph also mentions that notifications could fail to appear |
Sry, yes, I did forget to mention that file but I already had it in my project. In android/app/src/main/res/raw/keep.xml is this content:
|
I did initialise it with |
Try this before requestPermission
|
Doesn't help, so it still works perfectly fine with |
I'm not that familiar with Android development ecosystem but could it be to with how the keep.xml you have specifies strict mode and that it should keep resources in the drawable folder but the one you're looking to use is the ic_launcher icon within the mipmap folder? Perhaps this needs tweaking but I realise how odd that sounds as you would normally would think that icon is kept. Not sure if higher versions of Grade plugin explicitly require that you specify to keep the mipmap resources under strict mode. Though in my experience, normally specifying a proper notification would typically require a drawable as that would be what results from using, say, the Image Asset Studio (see https://developer.android.com/studio/write/image-asset-studio). Might be worth trying to use a drawable instead. I can't reproduce the issue using the example app either after I make it use the launcher icon and when I copy the content of the keep.xml over to it. I don't believe it would be an issue with the plugin either given the plugin's responsibility is to specify the icon (which it does) and resource shrinking issues would fall outside of it and depends on having the appropriate configuration |
Thank you for you help. I already also tried the safe mode in the keep.xml, didn't change the situation. Did you also try my proguard file? I hope everything is correct in this file. |
Yes I did and is what I meant when I had copied the content of it over. You either need someone who can look at your app in more depth or provide a link to a repo with a minimal app that can reproduce the issue. Doubtful there's anything the plugin to address given the nature of the problem as I touched on earlier |
Oh, ok, sry, I didn't understand you correctly then. I will try to implement a minimal example that has the same issue when I have time, I hope I get it done this week. |
FWIW I'm having a very similar issue. The only thing that seems to work is setting I understand this is very likely a configuration issue, but it seems exceptionally difficult to track down what isn't configured correctly. I followed the instructions in the README, but I haven't done Android dev in a long time and I'm sure I missed or overlooked something. I'll be combing through it as best I can over the coming days. @siherrmann Did you have any luck tracking down your issue? |
This was the ticket for me. I changed
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@drawable/*,@mipmap/*,@raw/*" /> and now the notifications show up. I know very little about Android resources, so I need to do some reading to figure out what this all means, but at least I know where to look now. |
For discoverability, here is what I saw in the logs before I added
|
Thank you very much, the mipmap was also the problem for me. Now everything works perfectly with code shrinking enabled. Probably it would be good to put the |
Closing since this was a configuration issue. There was already a link to the one used for the example app, a link to the Android docs and each app will configure things differently that I don't think that specific one warrants being in the readme. An example of this is some may want to specify the exact resources to keep rather than wildcards. This plugin also doesn't advise to use the launcher icon as the notification icon as was done here either. Note sing image asset studio (see https://developer.android.com/studio/write/image-asset-studio#notification) would've resulted in drawables and that from my understanding is better and more aligned with the official way as there would be assets for different device pixel densities. It would've also meant that the keep.xml file you had originally would've worked |
Describe the bug
Local notifications are not working with
shrinkResources true
. Disabling works, but that's not best practice.To Reproduce
I don't know whether my gradle version is too new so I'll include it:
android/build.gradle
android/app/build.gradle
android/app/main/AppManifest.xml
So all permissions should be set correctly.
Now, I think the most important thing is the proguard-rules.pro:
I put everything in there what I found what could help, there should not be anything left what is needed for the local notifications, is there? Is something missing?
Expected behavior
Yeah, expected behaviour would be a working plugin. ;)
Sample code to reproduce the problem
Without code shrinking everything works, so my code should be fine, shouldn't it?
The text was updated successfully, but these errors were encountered: