Comments (23)
I made a fork here:
https://github.com/lukaskurz/background_location/tree/master
This fork contains fixes for both the issues mentioned by @LukasP94 as well as the issues found in the other fork described by @sisalik1 .
I tested it on emulator with API 34 as well as API 29/30 on device, so it should work with both before/after API 33 changes.
from background_location.
I made a fork here:
https://github.com/lukaskurz/background_location/tree/master
This fork contains fixes for both the issues mentioned by @LukasP94 as well as the issues found in the other fork described by @sisalik1 .
I tested it on emulator with API 34 as well as API 29/30 on device, so it should work with both before/after API 33 changes.@lukaskurz I tried using your fork on my Samsung A52s (API 34), but it did not compile,
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:27:41 Const 'val' initializer should be a constant value e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:27:44 Unresolved reference: BackgroundLocationPlugin e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:96:17 Unresolved reference: Utils e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:207:19 Unresolved reference: BackgroundLocationPlugin e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:211:19 Unresolved reference: BackgroundLocationPlugin e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:241:15 Unresolved reference: BackgroundLocationPlugin e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:244:51 Unresolved reference: BackgroundLocationPlugin e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:168:9 Unresolved reference: Utils e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:177:13 Unresolved reference: Utils e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:252:13 Unresolved reference: Utils e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:255:13 Unresolved reference: Utils FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':background_location:compileDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more details
I was able to fix this by running flutter clean:
flutter clean
flutter pub get
flutter run
from background_location.
@LukasP94 I was facing the same issue. I have fixed that into this forked version
https://github.com/dharmik-dalwadi-seaflux/background_location
Usage
background_location:
git:
url: https://github.com/dharmik-dalwadi-seaflux/background_location.git
ref: master
from background_location.
@BWMuller can you please check this issue?
from background_location.
@nzackoya Sure. I'll have a look
from background_location.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
from background_location.
@LukasP94 I was facing the same issue. I have fixed that into this forked version https://github.com/dharmik-dalwadi-seaflux/background_location
Usage
background_location: git: url: https://github.com/dharmik-dalwadi-seaflux/background_location.git ref: master
This problem was cleared, but it also appears to have another problem, but all the permissions are given by the user:
E/AndroidRuntime(22305): FATAL EXCEPTION: main
E/AndroidRuntime(22305): Process: xxx.xxxxxx.xxx, PID: 22305
E/AndroidRuntime(22305): java.lang.RuntimeException: Unable to create service com.almoullim.background_location.LocationUpdatesService: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{e70f782 22305:xxx.xxxxxx.xxx/u0a447} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
E/AndroidRuntime(22305): at android.app.ActivityThread.handleCreateService(ActivityThread.java:5111)
E/AndroidRuntime(22305): at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
E/AndroidRuntime(22305): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2506)
E/AndroidRuntime(22305): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(22305): at android.os.Looper.loopOnce(Looper.java:230)
E/AndroidRuntime(22305): at android.os.Looper.loop(Looper.java:319)
E/AndroidRuntime(22305): at android.app.ActivityThread.main(ActivityThread.java:8893)
E/AndroidRuntime(22305): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(22305): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
E/AndroidRuntime(22305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
E/AndroidRuntime(22305): Caused by: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{e70f782 22305:xxx.xxxxxx.xxx/u0a447} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
E/AndroidRuntime(22305): at android.os.Parcel.createExceptionOrNull(Parcel.java:3069)
E/AndroidRuntime(22305): at android.os.Parcel.createException(Parcel.java:3053)
E/AndroidRuntime(22305): at android.os.Parcel.readException(Parcel.java:3036)
E/AndroidRuntime(22305): at android.os.Parcel.readException(Parcel.java:2978)
E/AndroidRuntime(22305): at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7214)
E/AndroidRuntime(22305): at android.app.Service.startForeground(Service.java:775)
E/AndroidRuntime(22305): at com.almoullim.background_location.LocationUpdatesService.updateNotification(LocationUpdatesService.kt:177)
E/AndroidRuntime(22305): at com.almoullim.background_location.LocationUpdatesService.onCreate(LocationUpdatesService.kt:156)
E/AndroidRuntime(22305): at android.app.ActivityThread.handleCreateService(ActivityThread.java:5098)
E/AndroidRuntime(22305): ... 9 more
from background_location.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
from background_location.
Same here
from background_location.
I made a fork here:
https://github.com/lukaskurz/background_location/tree/master
This fork contains fixes for both the issues mentioned by @LukasP94 as well as the issues found in the other fork described by @sisalik1 .
I tested it on emulator with API 34 as well as API 29/30 on device, so it should work with both before/after API 33 changes.
@lukaskurz I tried using your fork on my Samsung A52s (API 34), but it did not compile,
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:27:41 Const 'val' initializer should be a constant value
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:27:44 Unresolved reference: BackgroundLocationPlugin
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:96:17 Unresolved reference: Utils
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:207:19 Unresolved reference: BackgroundLocationPlugin
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:211:19 Unresolved reference: BackgroundLocationPlugin
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:241:15 Unresolved reference: BackgroundLocationPlugin
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:244:51 Unresolved reference: BackgroundLocationPlugin
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:168:9 Unresolved reference: Utils
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:177:13 Unresolved reference: Utils
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:252:13 Unresolved reference: Utils
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:255:13 Unresolved reference: Utils
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':background_location:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
from background_location.
same here
from background_location.
I made a fork here:
https://github.com/lukaskurz/background_location/tree/master
This fork contains fixes for both the issues mentioned by @LukasP94 as well as the issues found in the other fork described by @sisalik1 .
I tested it on emulator with API 34 as well as API 29/30 on device, so it should work with both before/after API 33 changes.
None of the solutions work for me!
Manifest:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
App crashes:
java.lang.RuntimeException: Unable to create service com.almoullim.background_location.LocationUpdatesService: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{2e22cea 7459:com.techilex.oilcom.oilcom/u0a680} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
from background_location.
None of the previous solutions work for me :(
note: all required permissions are allowed.
Error text:
Caused by: java.lang.SecurityException: com.rose_holding.rose_app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
from background_location.
I made a fork here:
https://github.com/lukaskurz/background_location/tree/master
This fork contains fixes for both the issues mentioned by @LukasP94 as well as the issues found in the other fork described by @sisalik1 .
I tested it on emulator with API 34 as well as API 29/30 on device, so it should work with both before/after API 33 changes.@lukaskurz I tried using your fork on my Samsung A52s (API 34), but it did not compile,
e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:27:41 Const 'val' initializer should be a constant value e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:27:44 Unresolved reference: BackgroundLocationPlugin e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:96:17 Unresolved reference: Utils e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:207:19 Unresolved reference: BackgroundLocationPlugin e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:211:19 Unresolved reference: BackgroundLocationPlugin e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:241:15 Unresolved reference: BackgroundLocationPlugin e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt:244:51 Unresolved reference: BackgroundLocationPlugin e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:168:9 Unresolved reference: Utils e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:177:13 Unresolved reference: Utils e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:252:13 Unresolved reference: Utils e: file:///C:/Users/pc-name/AppData/Local/Pub/Cache/git/background_location-55c7845ce11b72975ab529d2b2fdf1c982fa01a8/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt:255:13 Unresolved reference: Utils FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':background_location:compileDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more details
I was able to fix this by running flutter clean:
flutter clean flutter pub get flutter run
i can confirm that using the forked repo from @lukaskurz now the app works fine, i hope these fixes will be merged into official plugin repo
from background_location.
How this issue still hangs here, there are solution suggestions and so many developers needs this. Do you still maintain this package @Almoullim ?
from background_location.
@BWMuller thanks man
from background_location.
Hey guys, any news on the fix?
from background_location.
@nzackoya @darkrevenger Currently the main issue with this repo being updated is the lack of independent verification of PRs. I know that this SDK34 issue is fixed in #208 as I haven't experienced it myself in my own prod deployed application.
I haven't managed to get a UI test to work where it successfully grants the permissions required and does a mock location event as the independent test. If anyone here has experience in that please give it a try so that we can have a easier update cycles.
Alternatively have a look at the PR, test it on your side and add a comment there if you found any issues. That way "independent" would just change to multiple external people vouching instead which should make it easier for @MoralCode to verify
from background_location.
@BWMuller seems the fix has been merged already, I just noticed, it is on master branch already, but not released to pub.dev. Tried the lates code from the master branch, the issue is fixed, works fine so far, not sure if it need some more tests. I guess it just needs a release to pub.dev
from background_location.
add these permission
use this fork
background_location:
git:
url: https://github.com/dharmik-dalwadi-seaflux/background_location.git
ref: master
then it will work and make sure to use like this class
class LocationBackgroundController extends GetxController {
@override
void onInit() {
super.onInit();
requestLocationPermission();
}
Future<void> requestLocationPermission() async {
var status = await Permission.locationAlways.status;
if (!status.isGranted) {
status = await Permission.locationAlways.request();
}
if (status.isGranted) {
configureBackgroundLocation();
} else {
// Handle permission denial
print("Location permission denied");
}
}
Future<void> configureBackgroundLocation() async {
await BackgroundLocation.setAndroidNotification(
title: "Background Location",
message: "Tracking location...",
icon: "@mipmap/ic_launcher",
);
// Set the location update interval to 5 seconds
BackgroundLocation.setAndroidConfiguration(5000);
BackgroundLocation.startLocationService();
BackgroundLocation.getLocationUpdates((location) {
// Handle location updates here
print("Latitude: ${location.latitude}, Longitude: ${location.longitude}");
});
startBackLocation();
}
void startBackLocation() async {
Timer.periodic(const Duration(seconds: 5), (timer) async {
await getBackgroundLocation();
});
}
Future<void> getBackgroundLocation() async {
var status = await Permission.locationAlways.status;
if (status.isGranted) {
// The location service is already started in configureBackgroundLocation
// No need to call startLocationService again
BackgroundLocation.getLocationUpdates((location) {
// Handle location updates here
print(
"Latitude: ${location.latitude}, Longitude: ${location.longitude}");
});
} else {
// Request permission if not granted
await Permission.locationAlways.request();
}
}
}
from background_location.
@BWMuller seems the fix has been merged already, I just noticed, it is on master branch already, but not released to pub.dev. Tried the lates code from the master branch, the issue is fixed, works fine so far, not sure if it need some more tests. I guess it just needs a release to pub.dev
Unfortunately i dont have access to pub.dev. If the fix for this is already on main i can make a "pending release" tag to make the status clearer. Ill go do that
from background_location.
Some hint for publishing a new version for a existing app with the above changes via Google Play Store:
I have a automated build pipeline which pblish my app into the internal test track in Google Play Store.
After consuming the master branch of "background_location" in my app and try to publish this in Playstore, I got the error: "You must let us know whether your app uses any Foreground Service permissions.".
The only way I found to solve this, is to manually upload the aab file to the track. Only then I got a new policy declaration entry in "App content" section where I have to explain why my app needs the foreground service.
from background_location.
It's not related to the issue above.
You can find a notification service called in foreground in LocationUpdateService.kt
Therefore you must add ForgroundService declaration.
[https://developer.android.com/develop/background-work/services/foreground-services]
from background_location.
Related Issues (20)
- Requesting Contributors HOT 9
- Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent HOT 2
- Lexical or Preprocessor Issue (Xcode): 'background_location/background_location-Swift.h' file not found HOT 5
- not working when app killed on Android HOT 23
- Not Working on reel devices iOS 17 but work correct-jy on android emulator HOT 3
- Allow disabling blue location usage bar when app is Always authorized to use location and running in background HOT 4
- Is there any property for direction? HOT 1
- Used for targetSdkVerison 34 HOT 1
- getLocationUpdates is not triggered after locking screen HOT 3
- Location not working in the background nor in forground HOT 2
- Accessing Location HOT 2
- Enabling Location access while screen is off HOT 2
- CI should not be trying to push to pub.dev for runs triggered by pull requests HOT 4
- Background location is poor quality on Android HOT 1
- Bug in Background HOT 4
- java.lang.RuntimeException: Unable to create service com.almoullim.background_location.LocationUpdatesService: java.lang.SecurityException: com.throttle.app.throttlemvp: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts HOT 3
- Conflict between BackgroundLocation.getLocationUpdates and FirebaseMessaging.onBackgroundMessage HOT 3
- Can you help me? HOT 1
- Location not fetching in android HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from background_location.