ekasetiawans / flutter_background_service

251 stars 165 forks source link

flutter_background_service_android build problem. #390

Closed joyhope closed 6 months ago

joyhope commented 6 months ago

I meet the problem

flutter_background_service_android-6.2.1/android/src/main/AndroidManifest.xml:10:9-16:15: AAPT: error: 'dollar_openBracket_foregroundServiceType_closeBracket' is incompatible with attribute foregroundServiceType (attr) flags [camera=64, connectedDevice=16, dataSync=1, health=256, location=8, mediaPlayback=2, mediaProjection=32, microphone=128, phoneCall=4, remoteMessaging=512, shortService=2048, specialUse=1073741824, systemExempted=1024].

In the build.gradle

manifestPlaceholders.foregroundServiceType = "mediaPlayback"

It still report tyep error.

joyhope commented 6 months ago

The same as #383

walulyafrancis commented 6 months ago

if you want to ship the project fast you can edit the plugin from cache as they release the fix, i faced the same issue and i edited it Got to C:\Users\myname\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_background_service_android-6.2.1\android\src\main\AndroidManifest.xml and edit attribute android:foregroundServiceType="" to for example android:foregroundServiceType="dataSync"

<application>
    <service
            android:enabled="true"
            android:exported="true"
            android:name=".BackgroundService"
            android:stopWithTask="false"
            android:foregroundServiceType="dataSync"
            />

its not a permanent solution, but it works if you want to release a fix fast on play store

joyhope commented 6 months ago

Good suggestion. It works around.

FaizanKadodiya commented 6 months ago

Is there any Complete Solution?

walulyafrancis commented 6 months ago

Is there any Complete Solution?

i think we should wait for the permanent fix in the next version, because i tried adding it in the app build.gradle as the documentation suggest, but it didn't work

android {
    ...

    defaultConfig {
        ...
        // Replace this with the value to use for android:foregroundServiceType
        // eg 'camera', 'connectedDevice', 'location', etc
        manifestPlaceholders['foregroundServiceType'] = '...'
    }
}

This failed to work when i tried to build release

ekasetiawans commented 6 months ago

closing this as duplicated