Solution: Traccar Client not sending locations in background on Motorola (Android 15)

Asty 7 hours ago

I struggled with this for a while and finally found a solution that worked, so I'm sharing in case it helps others.
Symptoms:

Manual "Send location" worked fine
Automatic background updates stopped after a short time
All battery optimizations were disabled for the app
Background activity was allowed
Location permission set to "Allow all the time"
Wakelock enabled in Traccar settings
Stop Detection disabled, distance filter set to 0, heartbeat interval 60s

Diagnosis:
After enabling debug logs, I found this error repeating every time the heartbeat fired:
ERROR [FgsLaunchGate startService]
Failed to start foreground service: startForegroundService() not allowed
due to mAllowStartForeground false:
service org.traccar.client/com.transistorsoft.locationmanager.service.LocationRequestService

android.app.ForegroundServiceStartNotAllowedException
Android was silently blocking the app from starting its foreground service when the heartbeat alarm fired in the background, even though all the standard "battery optimization" settings looked correct in the UI. This is a restriction introduced in Android 12+ that isn't always exposed through normal settings menus.
Solution — grant foreground service permissions via ADB:

Enable Developer Options on the phone (tap Build Number 7 times)
Enable USB Debugging
Install ADB / Platform Tools on a computer
Connect the phone via USB and authorize the connection
Run these commands:

adb shell cmd appops set org.traccar.client START_FOREGROUND allow
adb shell cmd appops set org.traccar.client RUN_IN_BACKGROUND allow
adb shell cmd appops set org.traccar.client RUN_ANY_IN_BACKGROUND allow
adb shell dumpsys deviceidle whitelist +org.traccar.client

Toggle the Status switch in Traccar Client off and on to restart the service with the new permissions

After this, locations started flowing reliably every 60 seconds, even with the screen off and the app in the background for hours.
Device: Motorola g06 power Android 15

Hope this helps someone — the standard troubleshooting guide doesn't mention these hidden AppOps and they're invisible in regular system settings.

Asty 6 hours ago

Following up on my previous post, the initial set of commands fixed the ForegroundServiceStartNotAllowedException, but after about an hour of the phone being stationary, a new error started appearing:

android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException:
Context.startForegroundService() did not then call Service.startForeground()

The app was being throttled by Android's Doze Mode — heartbeat intervals were drifting from the configured 60s up to 2, 4, even 7 minutes between successful POSTs, and eventually the foreground service couldn't start fast enough (Android's 5-second limit) before getting killed.
The previous command list was incomplete. Here's the extended set I'm now using:

adb shell dumpsys deviceidle whitelist +org.traccar.client
adb shell cmd appops set org.traccar.client START_FOREGROUND allow
adb shell cmd appops set org.traccar.client RUN_IN_BACKGROUND allow
adb shell cmd appops set org.traccar.client RUN_ANY_IN_BACKGROUND allow
adb shell cmd appops set org.traccar.client INSTANT_APP_START_FOREGROUND allow
adb shell cmd appops set org.traccar.client SYSTEM_ALERT_WINDOW allow
adb shell cmd appops set org.traccar.client WAKE_LOCK allow
adb shell cmd appops set org.traccar.client SCHEDULE_EXACT_ALARM allow
adb shell dumpsys deviceidle disable
Anton Tananaev 4 hours ago

Interesting. Why would foreground service be not allowed?

By the way, we're actively working on a new version of Traccar Client. It will be a fully open source without closed dependencies, so we'll have more control on what we can do. Hopefully it will help with some of these issues.

Kevin Powell 2 hours ago

Thank you for providing this Asty! I've been having some random issues with Android killing the foreground service as well with the Traccar client on my Motorola Android 15's. Will give this a try on a couple of them and see if it helps.