[英]Android null pointer exception in FirebaseVisionBarcodeDetectorOptions
//Here is the java code //这里是java代码
private FirebaseVisionBarcodeDetectorOptions options;
private FirebaseVisionBarcodeDetector detector;
options=new FirebaseVisionBarcodeDetectorOptions.Builder()
.setBarcodeFormats(FirebaseVisionBarcode.FORMAT_QR_CODE)
.build();
detector= FirebaseVision.getInstance().getVisionBarcodeDetector(options);
Dexter.withActivity(this).withPermission(Manifest.permission.CAMERA)
.withListener(new PermissionListener() {
@Override
public void onPermissionGranted(PermissionGrantedResponse response) {
showCamera();
}
@Override
public void onPermissionDenied(PermissionDeniedResponse response) {
common.showtoast("you must accept permission",BarcodescannerActivity.this);
}
@Override
public void onPermissionRationaleShouldBeShown(PermissionRequest permission, PermissionToken token) {
}
}).check();
I am implementing firebase QRcode scanner using ML-Kit in my android application.when i try to execute the code i am getting null pointer exception我正在我的 android 应用程序中使用 ML-Kit 实现 firebase QRcode 扫描器。当我尝试执行代码时,我收到空指针异常
Note:Here is the exception注意:这里是例外
java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.ml.vision.barcode.FirebaseVisionBarcodeDetector com.google.firebase.ml.vision.FirebaseVision.getVisionBarcodeDetector(com.google.firebase.ml.vision.barcode.FirebaseVisionBarcodeDetectorOptions)' on a null object reference java.lang.NullPointerException:尝试调用虚拟方法 'com.google.firebase.ml.vision.barcode.FirebaseVisionBarcodeDetector com.google.firebase.ml.vision.FirebaseVision.getVisionBarcodeDetector(com.google.firebase.ml.vision.barcode .FirebaseVisionBarcodeDetectorOptions)' 在空对象引用上
Is it possible that you haven't set up Firebase?您是否可能尚未设置 Firebase? The first step in the "Before you begin" section https://firebase.google.com/docs/ml-kit/android/read-barcodes “开始之前”部分的第一步https://firebase.google.com/docs/ml-kit/android/read-barcodes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.