mono0926 / barcode_scan2

[reborned barcode_scan] A flutter plugin for reading 2D barcodes and QR codes.
https://pub.dev/packages/barcode_scan2
MIT License
87 stars 78 forks source link

[Bug] Execution failed for task ':barcode_scan2:compileDebugKotlin'. #49

Closed Harishwarrior closed 2 years ago

Harishwarrior commented 2 years ago

Describe the bug The project throws an error after upgrading to flutter 3.0

To Reproduce

Logs

e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ActivityHelper.kt: (16, 1): Class 'ActivityHelper' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ActivityHelper.kt: (71, 5): 'onRequestPermissionsResult' overrides nothing
e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ActivityHelper.kt: (81, 58): Type mismatch: inferred type is Array<CapturedType(out String)>? but Array<(out) String!> was expected
e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ActivityHelper.kt: (81, 71): Type mismatch: inferred type is IntArray? but IntArray was expected
e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ChannelHandler.kt: (64, 39): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\RequestCameraPermissionHandler.kt: (8, 1): Class 'RequestCameraPermissionHandler' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\RequestCameraPermissionHandler.kt: (11, 5): 'onRequestPermissionsResult' overrides nothing

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':barcode_scan2:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details
Flutter 3.0

Additional context

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.0, on Microsoft Windows [Version 10.0.22000.675], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.67.0)
[√] Connected device (3 available)
[√] HTTP Host Availability

Possible cause

e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ActivityHelper.kt: (16, 1): Class 'ActivityHelper' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
Constans commented 2 years ago

It also happens on macOS:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.3.1 21E258 darwin-arm, locale en-NL)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.1)
[✓] IntelliJ IDEA Community Edition (version 2021.3)
[✓] VS Code (version 1.66.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!
Constans commented 2 years ago

Got it to work after manually solving the signalled issues in the de/mintware/barcode_scan/ActivityHelper.kt, de/mintware/barcode_scan/ChannelHandler.kt, and de/mintware/barcode_scan/RequestCameraPermissionHandler.kt files. Fixing means removing the ? operator.

Harishwarrior commented 2 years ago

Got it to work after manually solving the signalled issues in the de/mintware/barcode_scan/ActivityHelper.kt, de/mintware/barcode_scan/ChannelHandler.kt, and de/mintware/barcode_scan/RequestCameraPermissionHandler.kt files. Fixing means removing the ? operator.

Can you elaborate on how you fixed it?

Constans commented 2 years ago

The causing errors are really here for you:

e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ActivityHelper.kt: (81, 58): Type mismatch: inferred type is Array<CapturedType(out String)>? but Array<(out) String!> was expected
e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ActivityHelper.kt: (81, 71): Type mismatch: inferred type is IntArray? but IntArray was expected
e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ChannelHandler.kt: (64, 39): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected

The error tells you what was provided and what is expected. So you remove the trailing ? operator on these and provide what it expects. Then the other errors will go away because they complain about function signatures.

The long term fix will probably come from the package maintainer. This is just a fix to get your project building.

Harishwarrior commented 2 years ago

The causing errors are really here for you:

e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ActivityHelper.kt: (81, 58): Type mismatch: inferred type is Array<CapturedType(out String)>? but Array<(out) String!> was expected
e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ActivityHelper.kt: (81, 71): Type mismatch: inferred type is IntArray? but IntArray was expected
e: C:\Users\Harish\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barcode_scan2-4.2.0\android\src\main\kotlin\de\mintware\barcode_scan\ChannelHandler.kt: (64, 39): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected

The error tells you what was provided and what is expected. So you remove the trailing ? operator on these and provide what it expects. Then the other errors will go away because they complain about function signatures.

The long term fix will probably come from the package maintainer. This is just a fix to get your project building.

Thanks

as2a3 commented 2 years ago

@Harishwarrior If you solved this issue, can you upload files which had edited?

Harishwarrior commented 2 years ago

@Harishwarrior If you solved this issue, can you upload files which had edited?

I'll work on this tomorrow. Will update.

robinbonnes commented 2 years ago

I've created a PR here: https://github.com/mono0926/barcode_scan2/pull/50

You can use my repository for now, enter in your pubspec.yaml:

  barcode_scan2:
    git:
      url: https://github.com/robinbonnes/barcode_scan2
Harishwarrior commented 2 years ago

I've created a PR here: https://github.com/mono0926/barcode_scan2/pull/50

You can use my repository for now, enter in your pubspec.yaml:

  barcode_scan2:
    git:
      url: https://github.com/robinbonnes/barcode_scan2

Thanks man