yanshouwang / camerax

A camera plugin for flutter, which use CameraX on Android, native API on iOS, supports camera preview, capture and analyze.
MIT License
27 stars 15 forks source link

Type mismatch: inferred type is () -> Unit but Runnable! was expected #7

Closed xuala69 closed 3 years ago

xuala69 commented 3 years ago

I tried testing the package but when trying to run my app, I get the following error:

Parameter format not correct - e: C:\flutter.pub-cache\hosted\pub.dartlang.org\camerax-0.1.0\android\src\main\kotlin\dev\yanshouwang\camerax\CameraXHandler.kt: (87, 28): Type mismatch: inferred type is () -> Unit but Runnable! was expected e: C:\flutter.pub-cache\hosted\pub.dartlang.org\camerax-0.1.0\android\src\main\kotlin\dev\yanshouwang\camerax\CameraXHandler.kt: (97, 59): Type mismatch: inferred type is () -> Unit but Consumer<SurfaceRequest.Result!> was expected e: C:\flutter.pub-cache\hosted\pub.dartlang.org\camerax-0.1.0\android\src\main\kotlin\dev\yanshouwang\camerax\CameraXHandler.kt: (129, 59): Type mismatch: inferred type is (???) -> Unit? but Observer<in Int!> was expected e: C:\flutter.pub-cache\hosted\pub.dartlang.org\camerax-0.1.0\android\src\main\kotlin\dev\yanshouwang\camerax\CameraXHandler.kt: (129, 61): Cannot infer a type for this parameter. Please specify it explicitly. FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':camerax:compileDebugKotlin'. Compilation error. See log for more 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.

My Fluttter doctor -v is below

[√] Flutter (Channel stable, 2.0.4, on Microsoft Windows [Version 10.0.14393], locale en-IN) • Flutter version 2.0.4 at C:\flutter • Framework revision b1395592de (3 weeks ago), 2021-04-01 14:25:01 -0700 • Engine revision 2dce47073a • Dart version 2.12.2 [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\CH\AppData\Local\Android\sdk • Platform android-30, build-tools 30.0.3 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Android Studio (version 4.1.0) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) [√] VS Code (version 1.55.2) • VS Code at C:\Users\CH\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.21.0 [√] Connected device (2 available) • Redmi Note 9 Pro Max (mobile) • dce85400 • android-arm64 • Android 10 (API 29) • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.85 • No issues found!

yanshouwang commented 3 years ago

Can you run the example?

yanshouwang commented 3 years ago

I think the issue is because your project kotlin version doesn't match the plugin's, I use ext.kotlin_version = '1.4.21', which in the build.gradle on project level

xuala69 commented 3 years ago

Was the kotlin version. Solved thanks