I recently had an issue with ZXing.Maui that caused my app to crash every time I tried to open the barcode scanner view.
First error:
[CameraX] Failed to retrieve default CameraXConfig.Provider from meta-data
which leads into the thrown error:
CameraX is not configured properly. The most likely cause is you did not include a default implementation in your build such as 'camera-camera2'.
All the tutorials and instructions always just seemed to work, but my project never did. I finally found the issue. I had to add the following code to my MainApplication.cs file:
using AndroidX.Camera.Camera2;
using AndroidX.Camera.Core;
public class MainApplication : MauiApplication, CameraXConfig.IProvider
{
...
public CameraXConfig CameraXConfig => Camera2Config.DefaultConfig();
I added the 'CameraXConfig.IProvider' interface to my main app, and returned 'Camera2Config.DefaultConfig()' from the implemented function.
My project was ported from Xamarin.Forms, so that may have been part of the issue.
I doubt this was caused by ZXing.Maui, as others are using the library without issue, but I wanted to add this issue to the ZXing.Maui project as a workaround for others that may run into the same issue, rather than losing a week of development time to it. Hope that's okay to do.
I recently had an issue with ZXing.Maui that caused my app to crash every time I tried to open the barcode scanner view.
First error:
which leads into the thrown error:
All the tutorials and instructions always just seemed to work, but my project never did. I finally found the issue. I had to add the following code to my MainApplication.cs file:
I added the 'CameraXConfig.IProvider' interface to my main app, and returned 'Camera2Config.DefaultConfig()' from the implemented function.
My project was ported from Xamarin.Forms, so that may have been part of the issue.
I doubt this was caused by ZXing.Maui, as others are using the library without issue, but I wanted to add this issue to the ZXing.Maui project as a workaround for others that may run into the same issue, rather than losing a week of development time to it. Hope that's okay to do.
Feel free to close this issue.