flutter_background_fetch icon indicating copy to clipboard operation
flutter_background_fetch copied to clipboard

[BUG] BackgroundFetchPlugin prevents app from accessing other project's Kotlin code

Open bradrushworth opened this issue 11 months ago • 0 comments

I've been struggling with this issue for a few days. It has been preventing me from building my app.

You can access my entire source code here: https://github.com/bradrushworth/nuptialflight

I'm getting the following error:

flutter build appbundle

e: file:///C:/Users/Brad/StudioProjects/nuptialflight/android/app/src/main/kotlin/au/com/bitbot/nuptialflight/AppWidgetProvider.kt:8:8 Unresolved reference: es
e: file:///C:/Users/Brad/StudioProjects/nuptialflight/android/app/src/main/kotlin/au/com/bitbot/nuptialflight/AppWidgetProvider.kt:9:8 Unresolved reference: es
e: file:///C:/Users/Brad/StudioProjects/nuptialflight/android/app/src/main/kotlin/au/com/bitbot/nuptialflight/AppWidgetProvider.kt:11:27 Unresolved reference: HomeWidgetProvider       
e: file:///C:/Users/Brad/StudioProjects/nuptialflight/android/app/src/main/kotlin/au/com/bitbot/nuptialflight/AppWidgetProvider.kt:16:5 'onUpdate' overrides nothing
e: file:///C:/Users/Brad/StudioProjects/nuptialflight/android/app/src/main/kotlin/au/com/bitbot/nuptialflight/AppWidgetProvider.kt:21:37 Unresolved reference: HomeWidgetLaunchIntent   

I've upgraded to the latest Gradle versions (e.g. 8.6), Kotlin versions (e.g. 1.9.22), and Android SDK versions (e.g. 34) but nothing helped. I migrated according to this: https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply. We discussed it over here: https://github.com/transistorsoft/flutter_background_fetch/issues/358

Turns out that the issue is related to the following entries in my pubspec.yaml:

  plugin:
    platforms:
      android:
        package: com.transistorsoft.flutter.backgroundfetch
        pluginClass: BackgroundFetchPlugin
      ios:
        pluginClass: BackgroundFetchPlugin

If I comment out that plugin, it builds fine. If I put it back in, it can't find the Kotlin code from other module I rely on: home_widget: ^0.4.1

Something about this plugin is preventing the https://pub.dev/packages/home_widget Kotlin code in https://github.com/ABausG/home_widget/tree/main/android/src/main/kotlin/es/antonborri/home_widget from being found properly.

I'm not sure what disabling this plugin does to the functionality of flutter_background_fetch. Other than this build issue, either module works individually (i.e. the Android widget without this plugin, or the background tasks and notifications without the widget), so there is just a bug in that plugin I think that excludes other Kotlin code from being included properly?

Please help, I'm lost and desperate...

bradrushworth avatar Mar 03 '24 06:03 bradrushworth