Skip to content

Commit

Permalink
[CameraView] Android - Fix SetSurfaceProvider crash
Browse files Browse the repository at this point in the history
  • Loading branch information
UlriCode committed Jan 16, 2025
1 parent 1935da5 commit 4f29adf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/CommunityToolkit.Maui.Camera/CameraManager.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected virtual async partial Task PlatformConnectCamera(CancellationToken tok

protected async Task StartUseCase(CancellationToken token)
{
if (resolutionSelector is null)
if (resolutionSelector is null || cameraExecutor is null)
{
return;
}
Expand All @@ -183,7 +183,7 @@ protected async Task StartUseCase(CancellationToken token)
imageCapture?.Dispose();

cameraPreview = new Preview.Builder().SetResolutionSelector(resolutionSelector).Build();
cameraPreview.SetSurfaceProvider(previewView?.SurfaceProvider);
cameraPreview.SetSurfaceProvider(cameraExecutor, previewView?.SurfaceProvider);

imageCapture = new ImageCapture.Builder()
.SetCaptureMode(ImageCapture.CaptureModeMaximizeQuality)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.4.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.4.1" />

<!-- Ensure Linker does not remove required libraries -->
<None Include="linker.xml" Pack="true" PackagePath="build\$(PackageId).LinkerConfigurationFile.xml" />
Expand Down

0 comments on commit 4f29adf

Please sign in to comment.