Flutter background foregroundServiceType 0x00000008 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest

I’m using flutter_background_service: ^5.0.7 along with geolocator: ^11.0.0 to start a background service and track the user location.

on android 14 I’m the application crashed when its attempting to start the service

i have included the required permissions and follows the flutter_background_service: ^5.0.7 documentation but still nothing.

the exception that I’m encountering

E/AndroidRuntime(20806): FATAL EXCEPTION: main
E/AndroidRuntime(20806): Process: com.example.procss, PID: 20806
E/AndroidRuntime(20806): java.lang.RuntimeException: Unable to create service id.flutter.flutter_background_service.BackgroundService: java.lang.IllegalArgumentException: foregroundServiceType 0x00000008 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest file
E/AndroidRuntime(20806):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:5111)
E/AndroidRuntime(20806):    at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
E/AndroidRuntime(20806):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2506)
E/AndroidRuntime(20806):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(20806):    at android.os.Looper.loopOnce(Looper.java:230)
E/AndroidRuntime(20806):    at android.os.Looper.loop(Looper.java:319)
E/AndroidRuntime(20806):    at android.app.ActivityThread.main(ActivityThread.java:8893)
E/AndroidRuntime(20806):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(20806):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
E/AndroidRuntime(20806):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
E/AndroidRuntime(20806): Caused by: java.lang.IllegalArgumentException: foregroundServiceType 0x00000008 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest file
E/AndroidRuntime(20806):    at android.os.Parcel.createExceptionOrNull(Parcel.java:3073)
E/AndroidRuntime(20806):    at android.os.Parcel.createException(Parcel.java:3053)
E/AndroidRuntime(20806):    at android.os.Parcel.readException(Parcel.java:3036)
E/AndroidRuntime(20806):    at android.os.Parcel.readException(Parcel.java:2978)
E/AndroidRuntime(20806):    at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7214)
E/AndroidRuntime(20806):    at android.app.Service.startForeground(Service.java:862)
E/AndroidRuntime(20806):    at androidx.core.app.ServiceCompat$Api34Impl.startForeground(ServiceCompat.java:241)
E/AndroidRuntime(20806):    at androidx.core.app.ServiceCompat.startForeground(ServiceCompat.java:172)
E/AndroidRuntime(20806):    at id.flutter.flutter_background_service.BackgroundService.updateNotificationInfo(BackgroundService.java:175)
E/AndroidRuntime(20806):    at id.flutter.flutter_background_service.BackgroundService.onCreate(BackgroundService.java:107)
E/AndroidRuntime(20806):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:5098)
E/AndroidRuntime(20806):    ... 9 more
E/AndroidRuntime(20806): Caused by: android.os.RemoteException: Remote stack trace:
E/AndroidRuntime(20806):    at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2171)
E/AndroidRuntime(20806):    at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1785)
E/AndroidRuntime(20806):    at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:15850)
E/AndroidRuntime(20806):    at android.app.IActivityManager$Stub.onTransact$setServiceForeground$(IActivityManager.java:11873)
E/AndroidRuntime(20806):    at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3499)
E/AndroidRuntime(20806): 

here is my permissions and the service in the manifest file:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />


    <service
        android:name=".flutter_background_service.BackgroundService"
        android:foregroundServiceType="location"
        />

also i have updated my android/build.gradle file :

    ext.kotlin_version = '1.8.10'
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}allprojects {
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}subprojects {
    project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

gradle-wrapper.properties

distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-7.5-all.zip

and finally main.dart

    androidConfiguration: AndroidConfiguration(
      // this will be executed when app is in foreground or background in separated isolate
      onStart: onStart,
      // auto start service
      autoStart: false,
      isForegroundMode: true,
      initialNotificationTitle: 'Background Service',
      initialNotificationContent: 'Location Service Running',
                            ///specifiying the service type
        foregroundServiceType: AndroidForegroundType.location,
        foregroundServiceNotificationId: 888
    ),
    iosConfiguration: IosConfiguration(
      // auto start service
      autoStart: false,
      // this will be executed when app is in foreground in separated isolate
      onForeground: onStart,

      ///Todo
      // you have to enable background fetch capability on xcode project
      //onBackground: onIosBackground,
    ),
  ); ````

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật