Skip to content

Conversation

@ne0rrmatrix
Copy link
Contributor

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:

  • Updated AndroidX Camera NuGet packages (Xamarin.AndroidX.Camera.Camera2, Xamarin.AndroidX.Camera.View, Xamarin.AndroidX.Camera.Extensions) from version 1.4.2.2 to 1.5.0, and added Xamarin.AndroidX.Activity.Ktx version 1.11.0 to the Android project.

UI/Data Binding Fixes:

  • Corrected the ItemDisplayBinding in CameraViewPage.xaml to 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

  • Fixes #

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional 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.

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.
Copilot AI review requested due to automatic review settings October 27, 2025 05:07
Copy link
Contributor

Copilot AI left a 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

ne0rrmatrix and others added 7 commits October 26, 2025 23:54
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.
Copy link
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ne0rrmatrix!

Just FYI - I added some comments in the code regarding these updated Android API Bindings.

Looking at the Android Docs, these Bindings return NonNull which means they never return a nullable object. My guess is that the C# Bindings returning a nullable object was just an oversight in the new .NET for Android bindings.

I've also added the breaking change label since this PR updates our AndroidX.Camera dependencies.

@TheCodeTraveler TheCodeTraveler added the breaking change This label is used for PRs that include a breaking change label Oct 31, 2025
@ne0rrmatrix
Copy link
Contributor Author

Thanks @ne0rrmatrix!

Just FYI - I added some comments in the code regarding these updated Android API Bindings.

Looking at the Android Docs, these Bindings return NonNull which means they never return a nullable object. My guess is that the C# Bindings returning a nullable object was just an oversight in the new .NET for Android bindings.

It is an issue I have talked to them about. It showed up around 1.6.x in media3 libraries. Some builders and some parameters currently are all red unless I add them. It will not build atm without those. But hopefully it will be fixed in dotnet 10 or 11.

@TheCodeTraveler TheCodeTraveler merged commit 035d9c9 into CommunityToolkit:main Oct 31, 2025
11 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

breaking change This label is used for PRs that include a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants