AmolGangadhare / flutter_barcode_scanner

Barcode scanner plugin for flutter. Supports barcode scanning for Android and iOS
https://pub.dev/packages/flutter_barcode_scanner
MIT License
379 stars 455 forks source link

Can't build app // multiple java errors #117

Closed Gunlek closed 4 years ago

Gunlek commented 4 years ago

Describe the bug While trying to build the app using the 'flutter build apk --split-per-abi' command, the console raises various java exceptions

To Reproduce Steps to reproduce the behavior:

  1. Install flutter_barcode_scanner (current version is 1.0.1)
  2. Build the apk for the app using 'flutter build apk' command

Expected behavior Should build correctly without errors

Logs

D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:10: error: cannot find symbol
import androidx.lifecycle.DefaultLifecycleObserver;
                         ^
  symbol:   class DefaultLifecycleObserver
  location: package androidx.lifecycle
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:33: error: cannot find symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
                                                    ^
  symbol:   class FlutterLifecycleAdapter
  location: package io.flutter.embedding.engine.plugins.lifecycle
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:308: error: cannot find symbol
            implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver {
                                                               ^
  symbol:   class DefaultLifecycleObserver
  location: class FlutterBarcodeScannerPlugin
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:266: error: cannot find symbol
            lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
                        ^
  symbol:   variable FlutterLifecycleAdapter
  location: class FlutterBarcodeScannerPlugin
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:268: error: incompatible types: FlutterBarcodeScannerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
            lifecycle.addObserver(observer);
                                  ^
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:295: error: incompatible types: FlutterBarcodeScannerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
        lifecycle.removeObserver(observer);
                                 ^
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:315: error: method does not override or implement a method from a supertype
        @Override
        ^
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:319: error: method does not override or implement a method from a supertype
        @Override
        ^
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:323: error: method does not override or implement a method from a supertype
        @Override
        ^
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:327: error: method does not override or implement a method from a supertype
        @Override
        ^
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:331: error: method does not override or implement a method from a supertype
        @Override
        ^
D:\Documents\Personnel\Programmation\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_barcode_scanner-1.0.1\android\src\main\java\com\amolg\flutterbarcodescanner\FlutterBarcodeScannerPlugin.java:336: error: method does not override or implement a method from a supertype
        @Override
        ^
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.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
12 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Smartphone (please complete the following information): Tested in emulator, worked correctly, not plateform dependent as it's the build step that goes wrong

Additional context The app were perfectly working in emulator or on any real device in debug mode few days ago, that's probably due to a flutter update ?

Gunlek commented 4 years ago

Fixed by updating Flutter to current latest version

Beanster199 commented 4 years ago

Having same error, already run flutter upgrade but still, any other suggestion ?

Gunlek commented 4 years ago

What's the flutter channel you're using ? Upgrading to stable channel solved the issue for me

Leoudayan commented 3 years ago

I am facing the same problem.. I have the latest version of flutter. any solution?

Leoudayan commented 3 years ago

I am using 1.22.5 stable channel (macOS).

Here are the errors that I am getting,


/Users/mr22726/.pub-cache/hosted/pub.dartlang.org/flutter_barcode_scanner-1.0.1/android/src/main/java/com/amolg/flutterbarcodescanner/FlutterBarcodeScannerPlugin.java:33: error: cannot find symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
                                                    ^
  symbol:   class FlutterLifecycleAdapter
  location: package io.flutter.embedding.engine.plugins.lifecycle
/Users/mr22726/.pub-cache/hosted/pub.dartlang.org/flutter_barcode_scanner-1.0.1/android/src/main/java/com/amolg/flutterbarcodescanner/FlutterBarcodeScannerPlugin.java:266: error: cannot find symbol
            lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
                        ^
  symbol:   variable FlutterLifecycleAdapter
  location: class FlutterBarcodeScannerPlugin
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.
2 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 --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
Exception: Gradle task assembleDebug failed with exit code 1
MuhammadAliKust commented 3 years ago

I have latest flutter version but still facing this issue, unable to build apk. Any solution??