/Users/macbook/.pub-cache/hosted/pub.dev/flutter_barcode_scanner-2.0.0/android/src/main/java/com/amolg/flutterbarcodescanner/FlutterBarcodeScannerPlugin.java:71: error: cannot find symbol private FlutterBarcodeScannerPlugin(FlutterActivity activity, final PluginRegistry.Registrar registrar) { ^ symbol: class Registrar location: interface PluginRegistry /Users/macbook/.pub-cache/hosted/pub.dev/flutter_barcode_scanner-2.0.0/android/src/main/java/com/amolg/flutterbarcodescanner/FlutterBarcodeScannerPlugin.java:78: error: cannot find symbol public static void registerWith(final PluginRegistry.Registrar registrar) { ^ symbol: class Registrar location: interface PluginRegistry /Users/macbook/.pub-cache/hosted/pub.dev/flutter_barcode_scanner-2.0.0/android/src/main/java/com/amolg/flutterbarcodescanner/FlutterBarcodeScannerPlugin.java:244: error: cannot find symbol final PluginRegistry.Registrar registrar, ^ symbol: class Registrar location: interface PluginRegistry Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':flutter_barcode_scanner:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
- Try:
Run with --info option to get more log output. Run with --scan to get full insights.
BUILD FAILED in 34s Running Gradle task 'assembleDebug'... 34,7s Error: Gradle task assembleDebug failed with exit code 1
After updating Flutter, I started my application.
/Users/macbook/.pub-cache/hosted/pub.dev/flutter_barcode_scanner-2.0.0/android/src/main/java/com/amolg/flutterbarcodescanner/FlutterBarcodeScannerPlugin.java:71: error: cannot find symbol private FlutterBarcodeScannerPlugin(FlutterActivity activity, final PluginRegistry.Registrar registrar) { ^ symbol: class Registrar location: interface PluginRegistry /Users/macbook/.pub-cache/hosted/pub.dev/flutter_barcode_scanner-2.0.0/android/src/main/java/com/amolg/flutterbarcodescanner/FlutterBarcodeScannerPlugin.java:78: error: cannot find symbol public static void registerWith(final PluginRegistry.Registrar registrar) { ^ symbol: class Registrar location: interface PluginRegistry /Users/macbook/.pub-cache/hosted/pub.dev/flutter_barcode_scanner-2.0.0/android/src/main/java/com/amolg/flutterbarcodescanner/FlutterBarcodeScannerPlugin.java:244: error: cannot find symbol final PluginRegistry.Registrar registrar, ^ symbol: class Registrar location: interface PluginRegistry Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':flutter_barcode_scanner:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
- Try:
Run with --info option to get more log output. Run with --scan to get full insights.
BUILD FAILED in 34s Running Gradle task 'assembleDebug'... 34,7s Error: Gradle task assembleDebug failed with exit code 1
After updating Flutter, I started my application.
Share Improve this question asked Feb 21 at 5:57 Moustapha MbouombouoMoustapha Mbouombouo 891 silver badge2 bronze badges 2- benamorn.medium/… – pskink Commented Feb 21 at 6:15
- 2 This package didn't support flutter 3.29 because it remove some API you have to downgrade your project version or migrate to another lib or fork this lib and made it compatible (read in first comment link) – Lightn1ng Commented Feb 21 at 8:57
1 Answer
Reset to default 4The issue you're facing is due to the flutter_barcode_scanner
library not being updated to support Flutter 3.29.0
. After this Flutter upgrade, some Android APIs were deprecated, and since the original flutter_barcode_scanner
package (last maintained 3 years ago) relies on outdated plugin APIs, it’s causing these compilation errors (e.g., PluginRegistry.Registrar is no longer available).
Here are a few solutions you can try:
- Use a Community Fix Branch: A fork of the library has been updated to work with Flutter 3.29. Add this to your pubspec.yaml:
flutter_barcode_scanner:
git:
url: https://github/decodevM/flutter_barcode_scanner.git
ref: flutter-3.29
Consider using
flutter_barcode_scanner_plus: ^3.0.8
, a community-maintained package that’s actively supported and works with recent Flutter releasesDowngrade Flutter to v3.27.1
Fork and Fix It Yourself: Refer to Flutter’s official migration guide for deprecated plugin APIs here: https://docs.flutter.dev/release/breaking-changes/plugin-api-migration