-
Couldn't load subscription status.
- Fork 461
Fix camera package fails to build with latest Maui version #2916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix camera package fails to build with latest Maui version #2916
Conversation
Enhanced null safety across CameraManager.android.cs by adding null-conditional operators (`?`) to prevent potential null reference exceptions. Updated `CameraViewPage.xaml` to bind `Picker` to `SelectedCamera.Name` for accurate UI display. Upgraded `Xamarin.AndroidX.Camera` dependencies to version 1.5.0 and added `Xamarin.AndroidX.Activity.Ktx` for improved functionality and compatibility. Adjusted `CameraProvider.android.cs` to handle null values and ensure robust camera initialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses a build failure in the Camera package that occurs after updating to .NET MAUI 9.0.120 by updating AndroidX Camera dependencies and adding null-safety checks throughout the Android camera implementation.
- Updates AndroidX Camera NuGet packages from version 1.4.2.2 to 1.5.0 and adds Xamarin.AndroidX.Activity.Ktx dependency
- Adds null-conditional operators throughout Android camera code to prevent potential null reference exceptions
- Corrects data binding in the sample app's camera picker UI
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| CommunityToolkit.Maui.Camera.csproj | Updates AndroidX Camera packages to v1.5.0 and adds Activity.Ktx dependency |
| CameraProvider.android.cs | Adds null-safety checks for camera characteristics and info objects |
| CameraManager.android.cs | Adds extensive null-conditional operators throughout camera initialization and capture code |
| CameraViewPage.xaml | Fixes ItemDisplayBinding to correctly reference camera name property |
samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml
Outdated
Show resolved
Hide resolved
Updated CameraViewPage.xaml to fix data binding issues by modifying the `ItemDisplayBinding` property of the `Picker`. Enhanced CameraManager.android.cs with the following changes: - Improved resolution selection logic in `UpdateCaptureResolution` by prioritizing higher resolution over capture rate. - Enhanced image capture quality in `StartUseCase` by setting capture mode to maximize quality and applying the resolution selector. - Added audio support and proper initialization for video recording in `PlatformStartVideoRecording`. These changes improve the overall functionality and quality of the camera features.
Co-authored-by: Copilot <[email protected]>
This pull request focuses on fixing an issue where updating Dotnet Maui to 9.0.120 and updating workloads will prevent Camera package from building successfully. Updates AndroidX Camera NuGet packages to newer versions, and makes minor corrections to UI data bindings.
Dependency Updates:
Xamarin.AndroidX.Camera.Camera2,Xamarin.AndroidX.Camera.View,Xamarin.AndroidX.Camera.Extensions) from version 1.4.2.2 to 1.5.0, and addedXamarin.AndroidX.Activity.Ktxversion 1.11.0 to the Android project.UI/Data Binding Fixes:
ItemDisplayBindinginCameraViewPage.xamlto properly bind the camera name from the selected camera.These changes collectively improve the stability and maintainability of the camera features, especially in scenarios where hardware or system APIs may return null values. ### Description of Change ###
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
Updated Camera package version to address issues with Android transitory packages error that prevents builds. This may not affect all users. I noticed it tonight. It was building fine yesterday. I did update the workloads.