flutter_background_service icon indicating copy to clipboard operation
flutter_background_service copied to clipboard

Cannot find symbol import io.flutter.plugin.common.PluginRegistry.Registrar

Open kazekkloss opened this issue 10 months ago • 22 comments

After updating Flutter to version 3.28, the flutter_background_service_android library (version 6.2.7) fails to build due to a breaking change in the Flutter API. Specifically, the issue is related to the use of the now-removed Registrar class from the io.flutter.plugin.common.PluginRegistry package.

Here is the error message: error: cannot find symbol
import io.flutter.plugin.common.PluginRegistry.Registrar;
^ symbol: class Registrar
location: interface PluginRegistry

This issue occurs because the Registrar API has been removed in recent versions of Flutter, and the library needs to be updated to use the FlutterPlugin API instead.

kazekkloss avatar Dec 21 '24 12:12 kazekkloss

Exactly the same issue. There is also in medium: https://benamorn.medium.com/today-i-learned-after-upgrading-to-flutter-3-29-0-7c7ab1a97975

serduero avatar Feb 16 '25 20:02 serduero

same here

yusufcakmak avatar Feb 17 '25 07:02 yusufcakmak

same issue also when i upgrade 1 year old project this issue came i commend on every package still i have issue

KishoreCreativeAppLap avatar Feb 19 '25 08:02 KishoreCreativeAppLap

Same...

daniel548604106 avatar Feb 19 '25 14:02 daniel548604106

awesome_notifications plugin is also breaking with same error after upgrading flutter sdk to 3.29. Any solutions to this please?

abjainri avatar Feb 19 '25 14:02 abjainri

same here with e: file:///Users/luanbatistadev/.pub-cache/hosted/pub.dev/flutter_inapp_purchase-5.6.1/android/src/main/kotlin/com/dooboolab/flutterinapppurchase/FlutterInappPurchasePlugin.kt:10:48 Unresolved reference: Registrar e: file:///Users/luanbatistadev/.pub-cache/hosted/pub.dev/flutter_inapp_purchase-5.6.1/android/src/main/kotlin/com/dooboolab/flutterinapppurchase/FlutterInappPurchasePlugin.kt:100:37 Unresolved reference: Registrar e: file:///Users/luanbatistadev/.pub-cache/hosted/pub.dev/flutter_keychain-2.5.0/android/src/main/kotlin/be/appmire/flutterkeychain/FlutterKeychainPlugin.kt:16:48 Unresolved reference: Registrar e: file:///Users/luanbatistadev/.pub-cache/hosted/pub.dev/flutter_keychain-2.5.0/android/src/main/kotlin/be/appmire/flutterkeychain/FlutterKeychainPlugin.kt:291:37 Unresolved reference: Registrar

luanbatistadev avatar Feb 20 '25 15:02 luanbatistadev

I got: C:\Users\name\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_plugin_android_lifecycle-2.0.19\android\src\main\java\io\flutter\plugins\flutter_plugin_android_lifecycle\FlutterAndroidLifecyclePlugin.java:19: error: cannot find symbol @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { ^ symbol: class Registrar location: interface PluginRegistry

dpnnl avatar Feb 23 '25 17:02 dpnnl

Same issue happening with Flutter Awesome Notifications package after upgrading latest version to flutter.

abhinavs1920 avatar Mar 17 '25 07:03 abhinavs1920

A temporary workaround is to downgrade your Flutter version until it's fully compatible. You can use flutter downgrade or doing a git checkout to the last major version inside your flutter SDK folder.

hantsaniala avatar Mar 17 '25 16:03 hantsaniala

For flutter Awesome Notifications, it worked when I upgraded it to the latest version 0.10.1

abhinavs1920 avatar Mar 17 '25 19:03 abhinavs1920

I think this issue is no longer related to flutter_background_service

ekasetiawans avatar Mar 17 '25 20:03 ekasetiawans

For the problematic packages which haven't done the migration yet, we can lobotomize them in your Pub Cache folder. Comment out the import and registerWith() method.

Take a look at this pull example: https://github.com/aakashkondhalkar/external_path/pull/13/files

txufiknr avatar Mar 18 '25 08:03 txufiknr

Running on an older version (e.g. 3.27.4) does the trick.

It seems to be related to some deprecated API. The warning you are likely to receive after running on the older version looks as follows:

Note: /Users/{user}/.pub-cache/hosted/pub.dev/flutter_secure_storage-4.2.1/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java uses or overrides a deprecated API.

nekear avatar Mar 19 '25 19:03 nekear

Running on an older version (e.g. 3.27.4) does the trick.

It seems to be related to some deprecated API. The warning you are likely to receive after running on the older version looks as follows:

Note: /Users/{user}/.pub-cache/hosted/pub.dev/flutter_secure_storage-4.2.1/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java uses or overrides a deprecated API.

Yeah, I don't know why many packages out there still call that old API, which is PluginRegistry.Registrar with @Suppress("unused") notation. That was deprecated a few years ago and is no longer used... since Flutter v2 actually. Because it was Flutter v1 method, bruh. 😭

That's what causes build failure on the latest flutter because that API has been completely removed.

txufiknr avatar Mar 20 '25 06:03 txufiknr

Running on an older version (e.g. 3.27.4) does the trick. It seems to be related to some deprecated API. The warning you are likely to receive after running on the older version looks as follows:

Note: /Users/{user}/.pub-cache/hosted/pub.dev/flutter_secure_storage-4.2.1/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java uses or overrides a deprecated API.

Yeah, I don't know why many packages out there still call that old API, which is PluginRegistry.Registrar with @Suppress("unused") notation. That was deprecated a few years ago and is no longer used... since Flutter v2 actually. Because it was Flutter v1 method, bruh. 😭

That's what causes build failure on the latest flutter because that API has been completely removed.

@topex-psy There is a 10.0.0 version of the flutter_secure_storage package coming out soon. Hope it will be migrated to the new APIs.

@juliansteenbakker Will 10.0.0 contain the migration from PluginRegistry.Registrar to something more up-to-date?

nekear avatar Mar 20 '25 21:03 nekear

/Users/infoera/.pub-cache/hosted/pub.dev/flutter_geofire-2.0.4/android/src/main/java/in/appyflow/geofire/GeofirePlugin.java:28: error: cannot find symbol import io.flutter.plugin.common.PluginRegistry.Registrar; ^ symbol: class Registrar location: interface PluginRegistry.

please resolve this issue

kunal02to11 avatar Mar 28 '25 10:03 kunal02to11

/Users/infoera/.pub-cache/hosted/pub.dev/flutter_geofire-2.0.4/android/src/main/java/in/appyflow/geofire/GeofirePlugin.java:28: error: cannot find symbol import io.flutter.plugin.common.PluginRegistry.Registrar; ^ symbol: class Registrar location: interface PluginRegistry.

please resolve this issue

Try downgrading your package version.

abhinavs1920 avatar Mar 28 '25 10:03 abhinavs1920

I believe the problem is related to this file:

packages/flutter_background_service_android/android/src/main/java/id/flutter/flutter_background_service/FlutterBackgroundServicePlugin.java

It has these lines:

public static void registerWith(FlutterEngine engine){ Log.d(TAG, "registering with FlutterEngine"); } When I remove these, I can build normally on Flutter version 3.29.3

EsbenSoeltoft avatar Apr 17 '25 17:04 EsbenSoeltoft

It's not a good way to lower the package version. Compatibility issues with other packages make the problem more complicated. How can I solve this? I have the same problem

evar-leeo avatar Apr 29 '25 05:04 evar-leeo

what causes build failure on the latest flutter because that API has been completely removed.

Note: /Users/{user}/.pub-cache/hosted/pub.dev/flutter_secure_storage-4.2.1/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java uses or overrides a deprecated API.

@topex-psy There is a 10.0.0 version of the flutter_secure_storage package coming out soon. Hope it will be migrated to the new APIs.

The latest stable version is 9.2.4 which is already migrated. v4.2.1 is a very old version.

juliansteenbakker avatar Apr 29 '25 06:04 juliansteenbakker

I'm also facing this issue after upgrading to Flutter 3.29.3. Any update on this issue?

Ellynnn avatar May 16 '25 06:05 Ellynnn

This is actually an outdated issue, after upgrading flutter, libs and code stuffs it works fine to me.

Mohit-Hasan avatar Jun 27 '25 13:06 Mohit-Hasan