App close after scanning barcode
See original GitHub issueDescribe the bug I got error while scanning barcode. Barcode value is shown in dart log, but app is stopped. I dont know i wrong in implementation or that’s a bug.
Smartphone (please complete the following information):
- Device: MI A1
- OS: Android 9
Log
> FATAL EXCEPTION: main
Process: com.mozdev.barcode_scan, PID: 15566
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9001, result=0, data=Intent { (has extras) }} to activity {com.mozdev.barcode_scan/com.mozdev.barcode_scan.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.MethodChannel$Result.success(java.lang.Object)' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4382)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4424)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1818)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.MethodChannel$Result.success(java.lang.Object)' on a null object reference
at com.amolg.flutterbarcodescanner.FlutterBarcodeScannerPlugin.onActivityResult(FlutterBarcodeScannerPlugin.java:157)
at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:634)
at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:367)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:546)
at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:594)
at android.app.Activity.dispatchActivityResult(Activity.java:7454)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4375)
Code
Future<void> scanBarcodeNormal(BuildContext context) async {
String barcodeScanRes;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(
"#ff6666", "Cancel", true, ScanMode.BARCODE);
print(barcodeScanRes);
} on PlatformException {
barcodeScanRes = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_scanBarcode = barcodeScanRes;
});
}
**Dart/Flutter Log**
> I/flutter (17677): 8999909000711
**Depedencies**
pubspec.yaml
flutter_barcode_scanner:
git:
url: git://github.com/AmolGangadhare/flutter_barcode_scanner.git
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:13 (4 by maintainers)
Top Results From Across the Web
App closes after scanning a Barcode · Issue #33 - GitHub
Hi, i got the problem that the scanner correctly detectes the barcode but closes the app without any error messages on Android.
Read more >Why does my phone crash when I scan barcodes - Google Help
As I proceeded to scan my items I noticed after the first scan my pixel 4xl goes black, and the only way to...
Read more >scan qrcode closing app instead of providing result
However, after scanning, the app immediately closes. No errors and no results. Just bye-bye.
Read more >How to Fix Barcode Scanner Not Working - Lose It! Support
This article will explain how to troubleshoot when the barcode scanner is not working. ... This will close any apps that were running...
Read more >Barcode Scanner - QR Scanner on the App Store - Apple
QR Code Reader & Barcode Scanner Free can be use as shopping assistant. -Jump directly to WEB ADDRESSES decoded.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have exactly the same issue on a HTC U11, also with Android 9.
I observed that, when I restart the application after the crash, it prints the QR code it was scanning just before the crash. So it seems the detection actually works. The behaviour is the same in debug and release mode.
The issue has been fixed in V 2.0.0.
Closing this as of now, feel free to open a new issue.