Closed Kumaravinash9 closed 3 years ago
After debugging it. It shows an error because of some permission issue when the app tried to run the background task.
Here is the error log :
PlatformException(PermissionError, The battery optimizations are not turned off., , null)
I forgot to add android permisions to the guide, check the android manifest https://gitlab.com/elRepo.io/elRepo.io-android/-/blob/develop/android/app/src/main/AndroidManifest.xml#L109
On August 21, 2021 10:46:26 PM GMT+02:00, Avinash Kumar @.> wrote: @. commented on this pull request.
- if (!permissionHandler!!.isIgnoringBatteryOptimizations()) {
- if (activity != null) {
- permissionHandler!!.requestBatteryOptimizationsOff(result, activity!!)
- } else {
- result.error("NoActivityError", "The plugin is not attached to an activity", "The plugin is not attached to an activity. This is required in order to request battery optimization to be off.")
- }
- }
- result.success(true)
- }
- "enableBackgroundExecution" -> {
- // Ensure all the necessary permissions are granted
- if (!permissionHandler!!.isWakeLockPermissionGranted()) {
- result.error("PermissionError", "Please add the WAKE_LOCK permission to the AndroidManifest.xml in order to use background_sockets.", "")
- } else if (!permissionHandler!!.isIgnoringBatteryOptimizations()) {
- result.error("PermissionError", "The battery optimizations are not turned off.", "")
the problem is coming here because of not a required permission.
-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/RetroShare/retroshare-mobile/pull/41#pullrequestreview-735520475
Try to uninstall and install again. Maybe you need to request permision again
On August 22, 2021 1:09:47 PM GMT+02:00, Avinash Kumar @.> wrote: @. commented on this pull request.
Still not working
-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/RetroShare/retroshare-mobile/pull/41#discussion_r693484848
Try to uninstall and install again. Maybe you need to request permision again On August 22, 2021 1:09:47 PM GMT+02:00, Avinash Kumar @.> wrote: @. commented on this pull request. …
+ + + + + + + + + + + + + + + Still not working -- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: #41 (comment)
Already tried it. Let me try it again. The steps I followed pervious :
Try to uninstall and install again. Maybe you need to request permision again On August 22, 2021 1:09:47 PM GMT+02:00, Avinash Kumar @.> wrote: @. commented on this pull request. …
+ + + + + + + + + + + + + + + Still not working -- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: #41 (comment)
It didn't work.
@csoler this issues is not removed yetPlatformException(PermissionError, The battery optimizations are not turned off., , null)
I mean to uninstall the application. You are not giving the correct permisions to the app from the android system
On August 22, 2021 8:35:53 PM GMT+02:00, Avinash Kumar @.***> wrote:
Try to uninstall and install again. Maybe you need to request permision again On August 22, 2021 1:09:47 PM GMT+02:00, Avinash Kumar @.> wrote: @. commented on this pull request.
+ + + + + + + + + + + + + + + Still not working -- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: #41 (comment) Already tried it. Let me try it again.
The steps I followed pervious :
Flutter clean
Flutter pub get
Flutter run
-- > You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/RetroShare/retroshare-mobile/pull/41#issuecomment-903311691
I mean to uninstall the application. You are not giving the correct permisions to the app from the android system … On August 22, 2021 8:35:53 PM GMT+02:00, Avinash Kumar @.> wrote: > Try to uninstall and install again. Maybe you need to request permision again On August 22, 2021 1:09:47 PM GMT+02:00, Avinash Kumar @.> wrote: @.** commented on this pull request. > … > > -
+ + + + + + + + + + + + + + + Still not working -- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: [#41 (comment)](#41 (comment)) Already tried it. Let me try it again. The steps I followed pervious : Flutter clean Flutter pub get Flutter run -- > You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: #41 (comment)
I have tried these steps. But didn't work. Do you mean I need to provide permission manually
@Kumaravinash9 what about this? You managed to fix the problem?
@Kumaravinash9 what about this? You managed to fix the problem?
No still same problem is coming. It's varies mobile to mobile.
PlatformException(PermissionError, The battery optimizations are not turned off., , null)
This error above is a permission error, you didn't tap the "Ok" in the acceptance dialog when permissions are requested. You saw this dialog? What version of Android are you using? Exactly in what line of the code you see this error?
A related piece of code for this are:
// Initialize RsServiceControl with default values
rsControl.RsServiceControl.initialize().then((value) {
print("RsServiceControl initialize Ok");
await rsControl.RsServiceControl.enableBackgroundExecution();
// Do whatever
});
When you initialize the program tests all the permissions and asks for the permissions if they are not set. Check over:
The error maybe is because your Android version? :thinking:
PlatformException(PermissionError, The battery optimizations are not turned off., , null)
This error above is a permission error, you didn't tap the "Ok" in the acceptance dialog when permissions are requested. You saw this dialog? What version of Android are you using? Exactly in what line of the code you see this error?
A related piece of code for this are:
// Initialize RsServiceControl with default values rsControl.RsServiceControl.initialize().then((value) { print("RsServiceControl initialize Ok"); await rsControl.RsServiceControl.enableBackgroundExecution(); // Do whatever });
When you initialize the program tests all the permissions and asks for the permissions if they are not set. Check over:
The error maybe is because your Android version? 🤔
Hii @selankon Actually, whatever changes you mentioned above I have done this before. Maybe this problem with new devices like android 11 because when I tried to run this on older devices. It ran but on the newly launched phone, It did not work.
So on devices newer than android 10 doesn't work right? I haven't one to test. May we check about bettery optimizations permissions on Android 11 to fix this
@Kumaravinash9 have you tried something like this: https://stackoverflow.com/a/68634616/4708664 ? What phone model have the problem? I remember that MIUI had some special specifications.
I remember that MIUI had some special specifications.
Actually i am using readmi note 10 pro having MIUI.
Witch version of MIUI and Android?
Witch version of MIUI and Android?
MIUI Global 12.0.5
and Android version : 11
We have to investigate about MIUI, Android11 and the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
permission.
May we don't really need it?
@selankon now this problem arise after doing all the required changes.