Skip to content

Commit e26f3b9

Browse files
authored
[camera_android]: Fixes crash when record video on Android versions lower than 12 (flutter#4635)
The the solution of the issue flutter#109769 in the flutter#7073 causes a crashes when the Android SDK version is lower than 31, due to EncoderProfiles not being found on these devices. This issue was solved putting the EncoderProfiles declaration after the check for SDK version. based on flutter/plugins#7073 by @camsim99. Fixes flutter#109769 in Android lower than 12.
1 parent fe6f67e commit e26f3b9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

packages/camera/camera_android/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.10.8+7
22

3+
* Fixes video record crash on Android versions lower than 12.
34
* Updates minimum supported SDK version to Flutter 3.7/Dart 2.19.
45

56
## 0.10.8+6

packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/Camera.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,8 @@ private void prepareMediaRecorder(String outputFilePath) throws IOException {
256256

257257
// TODO(camsim99): Revert changes that allow legacy code to be used when recordingProfile is null
258258
// once this has largely been fixed on the Android side. https://github.com/flutter/flutter/issues/119668
259-
EncoderProfiles recordingProfile = getRecordingProfile();
260-
if (SdkCapabilityChecker.supportsEncoderProfiles() && recordingProfile != null) {
261-
mediaRecorderBuilder = new MediaRecorderBuilder(recordingProfile, outputFilePath);
259+
if (SdkCapabilityChecker.supportsEncoderProfiles() && getRecordingProfile() != null) {
260+
mediaRecorderBuilder = new MediaRecorderBuilder(getRecordingProfile(), outputFilePath);
262261
} else {
263262
mediaRecorderBuilder = new MediaRecorderBuilder(getRecordingProfileLegacy(), outputFilePath);
264263
}

packages/camera/camera_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Android implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
55

6-
version: 0.10.8+6
6+
version: 0.10.8+7
77

88
environment:
99
sdk: ">=2.19.0 <4.0.0"

0 commit comments

Comments
 (0)