Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execution failed for task ':camera:compileDebugJavaWithJavac'

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.

like image 213
Tharindu Lakshan Avatar asked Nov 17 '21 06:11

Tharindu Lakshan


People also ask

What went wrong with compiledebugjavawithjavac?

* What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details. * Try: Run with --stacktrace option to get the stack trace.

What to do when build failed with an exception in Java?

`FAILURE: Build failed with an exception. Execution failed for task ' compileDebugJavaWithJavac'. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

How to view errors in Java compiler?

They are somewhat hidden, you have to expand the Java compiler node. You will see the errors there. But there is a better way to see the errors. You can click on the Toggle View button to get a better view of the error. That way you don't have to expand each node.

How to fix “JAVA_HOME is not working” error?

Sometimes, it might be the slightest error in your $JAVA_HOME configuration which is tabbing this error, just fix it like this: Double-check the build of your app. gradle. It adds an extra.jar file as a dependency that didn’t exist in your project. As a result, remove that and you’re back on track!


Video Answer


3 Answers

Try updating your compileSdkVersion and targetSdkVersion to 31.

like image 156
Dinithi De Silva Avatar answered Oct 28 '22 00:10

Dinithi De Silva


How about this? flutter pub cache repair

like image 32
Taz Avatar answered Oct 27 '22 23:10

Taz


I am facing same issue after spending a day came to conclusion we need to upgrated our flutter version.

flutter upgrade

Or

flutter upgrade --force
like image 1
Rahul Panzade Avatar answered Oct 28 '22 00:10

Rahul Panzade