Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unresolved reference: S #32

Closed
erueloi opened this issue Dec 3, 2021 · 5 comments
Closed

Unresolved reference: S #32

erueloi opened this issue Dec 3, 2021 · 5 comments

Comments

@erueloi
Copy link

erueloi commented Dec 3, 2021

When I compile the app with Visual Studio Code it gives me the following error:

e: C:\Projects\flutter.pub-cache\hosted\pub.dartlang.org\flutter_foreground_task-3.5.0\android\src\main\kotlin\com\pravera\flutter_foreground_task\service\ForegroundService.kt: (210, 53): Unresolved reference: S
e: C:\Projects\flutter.pub-cache\hosted\pub.dartlang.org\flutter_foreground_task-3.5.0\android\src\main\kotlin\com\pravera\flutter_foreground_task\service\ForegroundService.kt: (211, 13): Unresolved reference: setForegroundServiceBehavior
e: C:\Projects\flutter.pub-cache\hosted\pub.dartlang.org\flutter_foreground_task-3.5.0\android\src\main\kotlin\com\pravera\flutter_foreground_task\service\ForegroundService.kt: (211, 55): Unresolved reference: FOREGROUND_SERVICE_IMMEDIATE

Thks.

@Dev-hwang
Copy link
Owner

Dev-hwang commented Dec 3, 2021

#15 (comment)

Use the 'flutter clean' command as shown on this page.

@Ruud14
Copy link

Ruud14 commented Dec 5, 2021

I also have this issue and flutter clean doesn't seem to fix it.
I tried running flutter clean multiple times, together with the other steps mentioned in #15 But they don't work for my project.

I also tried it on the example, where I first changed the pubspec.yaml file to not get this package from ../, and there, indeed, the issue was fixed after running flutter clean.

Do you have any clue why this fix doesn't work on my project?

@Dev-hwang
Copy link
Owner

@erueloi, @Ruud14

Can you try setting the compileSdkVersion and targetSdkVersion values ​​to 31 in the app level build.gradle file?

android {
    compileSdkVersion 31

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.pravera.flutter_foreground_task_example"
        minSdkVersion 23
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    ...
}

And add the exported option to the MainActivity tag of the AndroidManifest file.

        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:exported="true"> // here

@Ruud14
Copy link

Ruud14 commented Dec 6, 2021

That worked!
Thanks a lot!

@Dev-hwang Dev-hwang pinned this issue Dec 6, 2021
@erueloi
Copy link
Author

erueloi commented Dec 7, 2021

Thks, it has worked for me too! ^^

@Dev-hwang Dev-hwang changed the title Error on ForegroundService.kt on compile flutter app Unresolved reference: S Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants