-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(barcode-scanning): NullPointerException
during startScan(...)
#107
Comments
This issue has been labeled as Please provide a Minimal, Reproducible Example using this template in a public GitHub repository so we can debug the issue. If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for us to reproduce the issue. |
It looks like there hasn't been a reply in 30 days, so I'm closing this issue. |
sorry to necrobump but im having the same issue on vue3, tried to add permissions and it even warned me of missing A vue based tutorial would be nice |
Please provide a Minimal, Reproducible Example (see How to create a Minimal, Reproducible Example) in a public GitHub repository so I can debug the issue. |
As you wish, give me an hour or so please, ill have to unfortunately use another minimal template as the problem seems to be more relating to vue/this repo interaction not the actual repo itself |
https://github.com/Imeguras/minimalVue Uncaught (in promise) Error: The Google Barcode Scanner Module is not available. You must install it first. |
ill atempt to fix it first |
Welp somehow i made it work? I've placed omited some minor steps althouth they were repetitive and tipically just "build" orders, ill try to fix my version and post any results here |
welp i somehow fixed it in my main repo, |
@Imeguras Can you share the commit that fixed it? |
Imeguras/minimalVue@21d377e
It fixed both minimal repo and the more complex project i was doing, however very different errors were presented in both one complained about missing some google bar reader library while the other was exactly equal to the one on the OP's post |
No, it shouldn't have anything to do with that. 🤔 I'm glad it's working for you now. |
I had the same issue. I fixed it by enabling data binding in the buildFeatures {
dataBinding true
}
dataBinding {
enabled = true
} When debugging the issue, I found that previewView is always null, which means it didn't detect the view or something like that (sorry, I'm not that familiar with how native Android apps are built). After enabling data binding, the issue is gone. New build.gradle: ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
androidxCameraCamera2Version = project.hasProperty('androidxCameraCamera2Version') ? rootProject.ext.androidxCameraCamera2Version : '1.1.0'
androidxCameraCoreVersion = project.hasProperty('androidxCameraCoreVersion') ? rootProject.ext.androidxCameraCoreVersion : '1.1.0'
androidxCameraLifecycleVersion = project.hasProperty('androidxCameraLifecycleVersion') ? rootProject.ext.androidxCameraLifecycleVersion : '1.1.0'
androidxCameraViewVersion = project.hasProperty('androidxCameraViewVersion') ? rootProject.ext.androidxCameraViewVersion : '1.1.0'
mlkitBarcodeScanningVersion = project.hasProperty('mlkitBarcodeScanningVersion') ? rootProject.ext.mlkitBarcodeScanningVersion : '17.1.0'
playServicesCodeScannerVersion = project.hasProperty('playServicesCodeScannerVersion') ? rootProject.ext.playServicesCodeScannerVersion : '16.0.0'
}
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
}
}
apply plugin: 'com.android.library'
android {
namespace "io.capawesome.capacitorjs.plugins.mlkit.barcodescanning"
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildFeatures {
dataBinding true
}
dataBinding {
enabled = true
}
}
repositories {
google()
mavenCentral()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':capacitor-android')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.camera:camera-camera2:$androidxCameraCamera2Version"
implementation "androidx.camera:camera-core:$androidxCameraCoreVersion"
implementation "androidx.camera:camera-lifecycle:$androidxCameraLifecycleVersion"
implementation "androidx.camera:camera-view:$androidxCameraViewVersion"
implementation "com.google.mlkit:barcode-scanning:$mlkitBarcodeScanningVersion"
implementation "com.google.android.gms:play-services-code-scanner:$playServicesCodeScannerVersion"
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
} |
@atoui-zahreddine That's strange. It doesn't work for me. Have you changed anything else? Btw: I can now reproduce the issue by simply installing the |
nope the only thing I changed is enabling data biding. Click to expand
|
@atoui-zahreddine Alright, seems like i'm doing anything wrong. It's still not working for me. I used the same patch. For this reason, I am reopening the issue. I also set a bounty of $50 to solve the issue. I am looking for a clean solution, not a workaround. There is no guarantee that a solution exists. Let me know if anyone wants to work on this. To reproduce the issue you can simply use the robingenz/capacitor-mlkit-plugin-demo repository and install the capacitor-community/apple-sign-in plugin. Nothing needs to be configured. |
NullPointerException
during startScan(...)
from what I can see, data binding should be enabled on the demo repository and on the plugin level. adding : buildFeatures {
dataBinding true
}
dataBinding {
enabled = true
} In demo-repo/android/app/build.gradle and @capacitor-mlkit/barcode-scanning/android/build.gradle should fix the issue ( it did for me) . I think there should be a better way to do this, I'll try to find an alternative to this. |
@atoui-zahreddine Thank you for the update. That worked for me. |
@robingenz great to hear that ! |
@atoui-zahreddine Yes, here you can find information on how to get paid. Thank you again for taking a look! Closed by #138 |
@robingenz Thank you! expense link : https://opencollective.com/capawesome/expenses/193657 |
@atoui-zahreddine Thanks. I've just approved your expense. |
Plugin(s)
Version
5.3.0
Platform(s)
Current behavior
I have a vue .js app (vue.js 2.0) and add barcode reader package but when start scan show me bellow error
startScan 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:211)
at android.os.Looper.loop(Looper.java:300)
at android.app.ActivityThread.main(ActivityThread.java:8437)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:560)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)
Expected behavior
Start Scanning
Reproduction
capawesome-team/.capacitor-app.
Steps to reproduce
Other information
No response
Capacitor doctor
[warn] The bundledWebRuntime configuration option has been deprecated. Can be safely deleted.
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: unknown
@capacitor/core: 5.5.1
@capacitor/android: 5.5.1
@capacitor/ios: 5.5.1
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/cli: 5.5.1
@capacitor/android: 5.5.1
@capacitor/core: 5.5.1
[success] Android looking great! 👌
Before submitting
The text was updated successfully, but these errors were encountered: