Dev-hwang / flutter_foreground_task

This plugin is used to implement a foreground service on the Android platform.
https://pub.dev/packages/flutter_foreground_task
MIT License
152 stars 112 forks source link

Android 14 not open #299

Closed srinathvgts closed 1 day ago

srinathvgts commented 3 days ago

e: file:///Users/srinathvishgyana/.pub-cache/hosted/pub.dev/flutter_foreground_task-8.14.0/android/src/main/kotlin/com/pravera/flutter_foreground_task/MethodCallHandlerImpl.kt:23:5 Unresolved reference: FlutterForegroundTaskPluginChannel e: file:///Users/srinathvishgyana/.pub-cache/hosted/pub.dev/flutter_foreground_task-8.14.0/android/src/main/kotlin/com/pravera/flutter_foreground_task/MethodCallHandlerImpl.kt:171:5 'init' overrides nothing e: file:///Users/srinathvishgyana/.pub-cache/hosted/pub.dev/flutter_foreground_task-8.14.0/android/src/main/kotlin/com/pravera/flutter_foreground_task/MethodCallHandlerImpl.kt:176:5 'setActivity' overrides nothing e: file:///Users/srinathvishgyana/.pub-cache/hosted/pub.dev/flutter_foreground_task-8.14.0/android/src/main/kotlin/com/pravera/flutter_foreground_task/MethodCallHandlerImpl.kt:180:5 'dispose' overrides nothing

Dev-hwang commented 3 days ago

@srinathvgts

This issue seems to be related to the local build cache.

try command

flutter clean
flutter pub get
flutter run
timsar2 commented 2 days ago

from android 14 it need to pass service type when going to startService,

https://developer.android.com/about/versions/14/changes/fgs-types-required#health service type like: healt data_sync ...

I think it's not implemented yet in this plugin.

Dev-hwang commented 2 days ago

@timsar2

check readme

You can specify the service type using the android:foregroundServiceType option as follows:

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

<!-- foregroundServiceType: dataSync -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

<!-- foregroundServiceType: health -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH" />

<!-- Warning: Do not change service name. -->
<service 
    android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
    android:foregroundServiceType="dataSync|health"
    android:exported="false" />

This plugin uses the ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST value to start the service, so you only need to specify the android:foregroundServiceType option.

https://github.com/Dev-hwang/flutter_foreground_task/blob/916289fd4fadbf1ebabf2c7715faf073504f4aa2/android/src/main/kotlin/com/pravera/flutter_foreground_task/service/ForegroundService.kt#L241

Dev-hwang commented 1 day ago

This issue is a known problem, and I believe it has been resolved through a build clean.

I will close this issue.