I am fetching notifications from api in background using android alarm manager plus & is working fine in debug mode but not in release version.
I am using redmi note 7.
According to flutter doctor all is fine.
I am fetching notifications from api in background using android alarm manager plus & is working fine in debug mode but not in release version.
I am using redmi note 7.
According to flutter doctor all is fine.
Do you have Internet permission to fetch data from the api? Check the AndroidManifest. Internet permission is set in debug mode, but removed in release. You have to set it manually.
<manifest xmlns:android...>
...
<uses-permission android:name="android.permission.INTERNET" />
<application ...
</manifest>
I ran into a same problem recently, couldn't really find help anywhere. I tried fixing it with help from this similar issue, but it didn't work for me (could've been doing something wrong). However, I found a temporary fix.
If you are running the app from cli, use --profile flag instead.
flutter run --profile
If you are building an apk, change the config to build the apk in profile mode and then sign the apk as if it was in release mode.
In android/app/build.gradle:
buildTypes {
release {
signingConfig signingConfigs.release
}
profile {
signingConfig signingConfigs.release
}
}
flutter build apk --profile
Note that the desired apk is now called app-profile.apk.
Flutter somehow changed the way build modes work. From what I understand, the android_alarm_manager libraries/plugin is not included in the release apk. You probably have to fix that using proguard, but I'm not sure how. Please note that building the apk in profile mode is not correct, but works as a temporary fix. I hope that someone more experienced can help us find the correct solution.
Hope this helps!
Regards, Honza