Reputation: 48
I got a piece of code from kivy wiki and with some changes managed to get it running
but i keep getting Starting FGS without a type
Error when i try to start the foreground service
The complete log:
jnius.jnius.JavaException: JVM exception occurred: Starting FGS without a type
callerApp=ProcessRecord{c9eb127 15990:org.laner.lan_ft:service_Sendnoti/u0a139}
targetSDK=35 android.app.MissingForegroundServiceTypeException
The Line it Crashes:
service.startForeground(1, notification_builder.getNotification())
I tried making the changes to the AndroidManifest.xml
but it kept overwriting and i don't know how/where to edit the template to set the service type, I understand i need to specify the service type in the AndroidManifest.xml
according to this Kotlin stack answer but i can't find anything on how to do that when using buildozer
Please Help !!!
Upvotes: 0
Views: 39
Reputation: 29
The most effective way to address this is by modifying the Buildozer spec file (buildozer.spec
) to inject the necessary XML into the AndroidManifest.xml. Here's how:
Edit buildozer.spec
: Add or modify the android.manifest_extra
setting within the [android]
section of your spec file:
```ini
[android]
# ... other android settings ...
android.manifest_extra = |
<service
android:name=".YourForegroundServiceClassName" # Replace with YOUR service class name
android:foregroundServiceType="location|camera|microphone|dataSync|mediaPlayback|phoneCall|connectedDevice|health|remoteMessenger|shortTasks" # Choose the appropriate type(s)
android:exported="false"> # Highly recommended: Add this for security
</service>
# ... rest of your buildozer.spec ...
After making these changes, clean and rebuild your APK.
Upvotes: 0