最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - Foreground Service Type Error, How to specify FGS type in buildozer.spec - Stack Overflow

programmeradmin4浏览0评论

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:.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 !!!

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:.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 !!!

Share Improve this question asked yesterday Fabian JosephFabian Joseph 388 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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.

发布评论

评论列表(0)

  1. 暂无评论