I have created a new flutter project and added camera
plugin. after adding that dependency I got many errors. I used futter version is 2.5.2
& minSdkVersion 21
In pubspec.yaml
file,
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.4
camera: ^0.9.4 4
Errors as follows,
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\Camera.java:23: error: cannot find symbol
import android.media.EncoderProfiles;
^
symbol: class EncoderProfiles
location: package android.media
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\Camera.java:935: error: cannot find symbol
EncoderProfiles getRecordingProfile() {
^
symbol: class EncoderProfiles
location: class Camera
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:10: error: cannot find symbol
import android.media.EncoderProfiles;
^
symbol: class EncoderProfiles
location: package android.media
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:29: error: cannot find symbol
private EncoderProfiles recordingProfile;
^
symbol: class EncoderProfiles
location: class ResolutionFeature
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:63: error: cannot find symbol
public EncoderProfiles getRecordingProfile() {
^
symbol: class EncoderProfiles
location: class ResolutionFeature
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:187: error: cannot find symbol
public static EncoderProfiles getBestAvailableCamcorderProfileForResolutionPreset(
^
symbol: class EncoderProfiles
location: class ResolutionFeature
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\media\MediaRecorderBuilder.java:8: error: cannot find symbol
import android.media.EncoderProfiles;
^
symbol: class EncoderProfiles
location: package android.media
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\media\MediaRecorderBuilder.java:24: error: cannot find symbol
private final EncoderProfiles encoderProfiles;
^
symbol: class EncoderProfiles
location: class MediaRecorderBuilder
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\media\MediaRecorderBuilder.java:36: error: cannot find symbol
@NonNull EncoderProfiles encoderProfiles, @NonNull String outputFilePath) {
^
symbol: class EncoderProfiles
location: class MediaRecorderBuilder
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\media\MediaRecorderBuilder.java:51: error: cannot find symbol
@NonNull EncoderProfiles encoderProfiles,
^
symbol: class EncoderProfiles
location: class MediaRecorderBuilder
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:186: error: cannot find symbol
@TargetApi(Build.VERSION_CODES.S)
^
symbol: variable S
location: class VERSION_CODES
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\Camera.java:208: error: reference to MediaRecorderBuilder is ambiguous
mediaRecorderBuilder = new MediaRecorderBuilder(getRecordingProfileLegacy(), outputFilePath);
^
both constructor MediaRecorderBuilder(CamcorderProfile,String) in MediaRecorderBuilder and constructor MediaRecorderBuilder(EncoderProfiles,String) in MediaRecorderBuilder match
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:118: error: cannot find symbol
EncoderProfiles profile =
^
symbol: class EncoderProfiles
location: class ResolutionFeature
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:120: error: package EncoderProfiles does not exist
List<EncoderProfiles.VideoProfile> videoProfiles = profile.getVideoProfiles();
^
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:121: error: package EncoderProfiles does not exist
EncoderProfiles.VideoProfile defaultVideoProfile = videoProfiles.get(0);
^
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:200: error: cannot find symbol
return CamcorderProfile.getAll(cameraIdString, CamcorderProfile.QUALITY_HIGH);
^
symbol: method getAll(String,int)
location: class CamcorderProfile
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:204: error: cannot find symbol
return CamcorderProfile.getAll(cameraIdString, CamcorderProfile.QUALITY_2160P);
^
symbol: method getAll(String,int)
location: class CamcorderProfile
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:208: error: cannot find symbol
return CamcorderProfile.getAll(cameraIdString, CamcorderProfile.QUALITY_1080P);
^
symbol: method getAll(String,int)
location: class CamcorderProfile
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:212: error: cannot find symbol
return CamcorderProfile.getAll(cameraIdString, CamcorderProfile.QUALITY_720P);
^
symbol: method getAll(String,int)
location: class CamcorderProfile
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:216: error: cannot find symbol
return CamcorderProfile.getAll(cameraIdString, CamcorderProfile.QUALITY_480P);
^
symbol: method getAll(String,int)
location: class CamcorderProfile
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:220: error: cannot find symbol
return CamcorderProfile.getAll(cameraIdString, CamcorderProfile.QUALITY_QVGA);
^
symbol: method getAll(String,int)
location: class CamcorderProfile
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:224: error: cannot find symbol
return CamcorderProfile.getAll(cameraIdString, CamcorderProfile.QUALITY_LOW);
^
symbol: method getAll(String,int)
location: class CamcorderProfile
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:241: error: package EncoderProfiles does not exist
List<EncoderProfiles.VideoProfile> videoProfiles = recordingProfile.getVideoProfiles();
^
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\features\resolution\ResolutionFeature.java:243: error: package EncoderProfiles does not exist
EncoderProfiles.VideoProfile defaultVideoProfile = videoProfiles.get(0);
^
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\media\MediaRecorderBuilder.java:32: error: reference to MediaRecorderBuilder is ambiguous
this(camcorderProfile, outputFilePath, new MediaRecorderFactory());
^
both constructor MediaRecorderBuilder(CamcorderProfile,String,MediaRecorderFactory) in MediaRecorderBuilder and constructor MediaRecorderBuilder(EncoderProfiles,String,MediaRecorderFactory) in MediaRecorderBuilder match
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\media\MediaRecorderBuilder.java:79: error: package EncoderProfiles does not exist
EncoderProfiles.VideoProfile videoProfile = encoderProfiles.getVideoProfiles().get(0);
^
C:\Users\Lakshan\Documents\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\camera-0.9.4 4\android\src\main\java\io\flutter\plugins\camera\media\MediaRecorderBuilder.java:80: error: package EncoderProfiles does not exist
EncoderProfiles.AudioProfile audioProfile = encoderProfiles.getAudioProfiles().get(0);
^
27 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':camera: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 16s
Exception: Gradle task assembleDebug failed with exit code 1
I tried clearing cache, but this issue occurs as same.
CodePudding user response:
How about this?
flutter pub cache repair
CodePudding user response:
1.Just delete flutter from root folder like "C:/src:/flutter"
2.Download from here [https://docs.flutter.dev/get-started/install/windows][1]
3.Set the path inside user variables under Edit environment variables.
4.Then just reset the path on android studio....
and again type flutter pub cache repair
CodePudding user response:
Try updating your compileSdkVersion and targetSdkVersion to 31.