Skip to content

[Camera] CamcorderProfile deprecated in Android API level 31 #89578

@andreidiaconu

Description

@andreidiaconu

The camera plugin can not be used with Android API level 31 because it uses a deprecated method and warnings are treated as errors.

Steps to Reproduce

  1. Start new project and use latest camera plugin
  2. Set compile and target API versions in your build.gradle file to API level 31:
compileSdkVersion = 31
targetSdkVersion = 31
  1. flutter build apk

Expected results: Build is successful

Actual results: Build fails with 8 warnings, treated as one error.

camera/features/resolution/ResolutionFeature.java:135: warning: [deprecation] get(int,int) in CamcorderProfile has been deprecated
           return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_HIGH);
                                  ^
camera/features/resolution/ResolutionFeature.java:139: warning: [deprecation] get(int,int) in CamcorderProfile has been deprecated
           return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_2160P);
                                  ^
camera/features/resolution/ResolutionFeature.java:143: warning: [deprecation] get(int,int) in CamcorderProfile has been deprecated
           return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_1080P);
                                  ^
camera/features/resolution/ResolutionFeature.java:147: warning: [deprecation] get(int,int) in CamcorderProfile has been deprecated
           return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_720P);
                                  ^
camera/features/resolution/ResolutionFeature.java:151: warning: [deprecation] get(int,int) in CamcorderProfile has been deprecated
           return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_480P);
                                  ^
camera/features/resolution/ResolutionFeature.java:155: warning: [deprecation] get(int,int) in CamcorderProfile has been deprecated
           return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_QVGA);
                                  ^
camera/features/resolution/ResolutionFeature.java:159: warning: [deprecation] get(int,int) in CamcorderProfile has been deprecated
           return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_LOW);
                                  ^
 error: warnings found and -Werror specified
camera/media/MediaRecorderBuilder.java:15: warning: [deprecation] MediaRecorder() in MediaRecorder has been deprecated
       return new MediaRecorder();
              ^
 1 error
 8 warnings

This affects #89511 which relands flutter/engine#24756 which requires Android API 31.

@blasten I'm pinging you here since you are most familiar with the affected issues and you also seem to have solved this in the past, when the camera did not work with API 30 flutter/plugins#3299 - I intend to also open a PR for this issue, but I still think you should be in the loop.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listfound in release: 2.2Found to occur in 2.2found in release: 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions