4

When executing Flutter run I'm getting the following error due to incompatibilities with the Camera plugin library.

Any ideas?

/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraPer
missions.java:12: error: package androidx.core.app does not exist
           import androidx.core.app.ActivityCompat;
                                   ^

/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraPer
missions.java:13: error: package androidx.core.content does not exist
           import androidx.core.content.ContextCompat;
                                       ^

/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraZoo
m.java:10: error: package androidx.core.math does not exist
           import androidx.core.math.MathUtils;
                                    ^

/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraPer
missions.java:45: error: cannot find symbol
                 ActivityCompat.requestPermissions(
                 ^
             symbol:   variable ActivityCompat
             location: class CameraPermissions

/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraPer
missions.java:58: error: cannot find symbol
               return ContextCompat.checkSelfPermission(activity, permission.CAMERA)
                      ^
             symbol:   variable ContextCompat
             location: class CameraPermissions

/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraPer
missions.java:63: error: cannot find symbol
               return ContextCompat.checkSelfPermission(activity, permission.RECORD_AUDIO)
                      ^
             symbol:   variable ContextCompat
             location: class CameraPermissions

/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraZoo
m.java:41: error: cannot find symbol
               final float newZoom = MathUtils.clamp(zoom, DEFAULT_ZOOM_FACTOR, this.maxZoom);
                                     ^
             symbol:   variable MathUtils
             location: class CameraZoom
           7 errors
           
           FAILURE: Build failed with an exception.
           
           * What went wrong:
           Execution failed for task ':compileReleaseJavaWithJavac'.
           > 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 5s
           
[   +7 ms] Exception: The plugin camera could not be built due to the issue above.
Dyan
  • 1,703
  • 4
  • 19
  • 26

1 Answers1

0

That is a problem with SDK vs plugin compatibility

Go to your build.grade file and check those:

android {
    compileSdkVersion 30 // must be 30 for compatibility

    defaultConfig {
        applicationId "tv.digicash"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

Check those too in Android Studio at your File > Project Structure (Project and SDKs left menus)

enter image description here

They must be 30 or superior

Alexander van Oostenrijk
  • 4,644
  • 3
  • 23
  • 37