Closed ctaddei closed 1 year ago
Made it start, now i'm getting an "Android chroma siting range" error
@ctaddei What did you do to make it start? I'm stuck with the error - Error: Attempt to invoke virtual method 'void androidx.camera.view.PreviewView.setScaleType(androidx.camera.view.PreviewView$ScaleType)' on a null object reference Error: Attempt to invoke virtual method 'void androidx.camera.view.PreviewView.setScaleType(androidx.camera.view.PreviewView$ScaleType)' on a null object reference
If I update capacitor versions I get error - MLKit Barcode Scanner Module not installed? Do you know anything about this?
@ctaddei we are running into this same issue. Do you mind sharing how you fixed it?
I'm getting the same error. Can you share how you fixed it?
Same trouble
also same issue
I fixed it by removing @capacitor-community/firebase-analytics plugin. When I removed it, the barcode scanner is working.
Well, i got same error and im not using firebase-analytics 🤔 Anyone solved it in different way?
For everyone using capacitor and the barcode scanner plugin coming from google, this solved the issue for me:
https://github.com/capawesome-team/capacitor-mlkit/issues/53#issuecomment-1732250659
The order of the plugins added to capacitor.build.gradle
seems to be the problem and adding the code from rdlabo to capacitor.config.json
solved the issue for me.
Anyone using biometric plugins? I am setting barcode scanning first and still encounter the problem.
Removing capgo-capacitor-native-biometric resolves the issue.
dependencies {
implementation project(':capacitor-mlkit-barcode-scanning')
implementation project(':capacitor-app')
implementation project(':capacitor-browser')
implementation project(':capacitor-device')
implementation project(':capacitor-geolocation')
implementation project(':capacitor-haptics')
implementation project(':capacitor-keyboard')
implementation project(':capacitor-push-notifications')
implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar')
implementation project(':capgo-capacitor-native-biometric')
}
same issue here
capacitor.config.ts
android: { includePlugins: [ '@capacitor-mlkit/barcode-scanning', '@capacitor-community/photoviewer', '@capacitor/app', '@capacitor/camera', '@capacitor/dialog', '@capacitor/geolocation', '@capacitor/haptics', '@capacitor/keyboard', '@capacitor/push-notifications', '@capacitor/status-bar' ] }
removing @capacitor-community/photoviewer will work, but i need both plugin
Hello, the issue is that plugin has to be imported first in the dependencies of the capacitor.build.gradle so to do that you need to make sure that in you package.json file under dependencies first imported plugin is this one (like in the image) and then it will always be automatically put first in the capacitor.build.gradle. When you change it as first just do npm install, npx cap sync and just rebuild the native project.
Package.json
"@capacitor-mlkit/barcode-scanning": "5.0.1",
"@capacitor/android": "^5.2.3",
"@capacitor/app": "^5.0.6",
"@capacitor/browser": "^5.0.6",
"@capacitor/core": "^5.2.3",
"@capacitor/device": "^5.0.6",
"@capacitor/geolocation": "^5.0.6",
"@capacitor/haptics": "^5.0.6",
"@capacitor/ios": "^5.2.3",
"@capacitor/keyboard": "^5.0.6",
"@capacitor/push-notifications": "^5.0.6",
"@capacitor/splash-screen": "^5.0.6",
"@capacitor/status-bar": "^5.0.6",
"@capgo/capacitor-native-biometric": "^5.0.1",
dependancies
dependencies {
implementation project(':capacitor-mlkit-barcode-scanning')
implementation project(':capacitor-app')
implementation project(':capacitor-browser')
implementation project(':capacitor-device')
implementation project(':capacitor-geolocation')
implementation project(':capacitor-haptics')
implementation project(':capacitor-keyboard')
implementation project(':capacitor-push-notifications')
implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar')
implementation project(':capgo-capacitor-native-biometric')
}
It looks like we both did that and are still seeing the problem
Was anyone able to solve this issue? I am having the same problem:
Error: "Attempt to invoke virtual method 'void androidx.camera.view.PreviewView.setScaleType(androidx.camera.view.PreviewView$ScaleType)' on a null object reference"
The problem I have is a conflict with the "@capacitor-community/photoviewer" plugin. If I remove that Plugin it works, but I need both.
@jchri853 Thank you for your response, it helped me resolve my issue but i had to run "npx cap sync" and "ionic build". If i only build, then it would revert to dependencies and order. After running sync then build in the same order as your response, it now works perfectly
Why is this closed and how was it fixed?! I'm still having issues with the biometric plugin and this package.
@TheCorbin Not sure this workaround would fix your problem, but it is worth to try:
Add/Update your bridge_layout_main.xml
in your app module (e.g. /android/app/src/main/res/layout/bridge_layout_main.xml
) with this to override the bridge_layout_main.xml
. You might need to import androidx.camera
library in build.gradle as well.
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.getcapacitor.BridgeActivity">
<androidx.camera.view.PreviewView
android:id="@+id/preview_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Describe the bug When calling startScan() in barcode-scanning-modal.component.ts i'm getting a "startScan failed", it opens the dialog with the interface, but its all black, camera is not starting.
ERROR:
s``` tartScan failed. 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:108) at io.capawesome.capacitorjs.plugins.mlkit.barcodescanning.BarcodeScanner.$r8$lambda$XoJ4tltbmXkBZjUvzn_RkQLTSis(Unknown Source:0) at io.capawesome.capacitorjs.plugins.mlkit.barcodescanning.BarcodeScanner$$ExternalSyntheticLambda3.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8757) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) 2023-08-30 11:20:50.876 27835-27835 Capacitor io.ionic.starter D Sending plugin error: {"save":false,"callbackId":"35338673","pluginId":"BarcodeScanner","methodName":"startScan","success":false,"error":{"message":"Attempt to invoke virtual method 'void androidx.camera.view.PreviewView.setScaleType(androidx.camera.view.PreviewView$ScaleType)' on a null object reference"}} 2023-08-30 11:20:50.883 27835-27835 Capacitor/Console io.ionic.starter E File: https://localhost/main.8d0c386ac6862cd3.js - Line 1 - Msg: ERROR Error: Uncaught (in promise): Error: Attempt to invoke virtual method 'void androidx.camera.view.PreviewView.setScaleType(androidx.camera.view.PreviewView$ScaleType)' on a null object reference Error: Attempt to invoke virtual method 'void androidx.camera.view.PreviewView.setScaleType(androidx.camera.view.PreviewView$ScaleType)' on a null object reference at returnResult (https://localhost/:768:32) at win.androidBridge.onmessage (https://localhost/:743:21)