6.1.0
Hi there.
So I have kind of a specific android app structure with multiple android fragments, and with capacitor instanciated in one of them using BridgeFragment
class. The particularity is that plugins are not automatically loaded when using this class, you have to manually add each plugin inside the fragment class as stated here ionic-team/capacitor#5564 (comment).
This works well, except for the barcode scanning plugin, which produces the famous NullPointerException
during startScan(...)
despite having data binding enabled.
java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.camera.view.PreviewView.setScaleType(androidx.camera.view.PreviewView$ScaleType)' on a null object reference
at io.capawesome.capacitorjs.plugins.mlkit.barcodescanning.BarcodeScanner.lambda$startScan$0(BarcodeScanner.java:106)
My guess is that the following code breaks because the app doesn't find the preview view since the plugin is instanciated in a fragment ?
// BarcodeScanner.java:106
previewView = plugin.getActivity().findViewById(R.id.preview_view);
I'm a beginner android developer so I'm kind of lost here as to where the problem lies exactly. I'm aware that my app's implementation with fragment is rather advanced so I'll understand if it's not something you want to support in your plugin.
No error during scan.
https://github.com/LoicUV/scanner-example
SCAN BARCODE
buttonNo response
π Capacitor Doctor π
Latest Dependencies:
@capacitor/cli: 6.1.0
@capacitor/core: 6.1.0
@capacitor/android: 6.1.0
@capacitor/ios: 6.1.0
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/cli: 6.1.0
@capacitor/android: 6.1.0
@capacitor/core: 6.1.0
[success] Android looking great! π
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too