AmolGangadhare / flutter_barcode_scanner

Barcode scanner plugin for flutter. Supports barcode scanning for Android and iOS
https://pub.dev/packages/flutter_barcode_scanner
MIT License
379 stars 453 forks source link

Crash on Android #47

Closed vkusenko closed 4 years ago

vkusenko commented 4 years ago

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 com.amolg.flutterbarcodescanner.FlutterBarcodeScannerPlugin.onActivityResult

AmolGangadhare commented 4 years ago

@vkusenko Try to bump up flutter app android compileSdkVersion and targetSdkVersion to 29 which is Android 10 and run the app.

I'll still be checking any possibility of reproducing this issue.

zulandar commented 4 years ago

I ran a bare min example and it worked successfully for me.

minSdkVersion 16
targetSdkVersion 28
wurstnudl commented 4 years ago

Nope, it doesn't work when pressing the "Cancel" button.

I assume the reason is that the field "pendingResult" is never actually set when cancelling (this would happen in "onMethodCall"), "onActivityResult" is being called and "pendingResult" is null.

wurstnudl commented 4 years ago

Nope, sorry, scanning also fails with a nullpointer at

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)

I'm using a github reference in the pubspec because otherwise, the app crashes on start up. See other related issues.

I'm running an Android 10. FlutterVersion = v1.12.13+hotfix.6

Edit: Tried switching to flutter beta channel with v1.13.6. No change.

AmolGangadhare commented 4 years ago

@wurstnudl

Thanks for the details.

I am not able to reproduce this issue. But In flutter v1.12.13 there is a migration to new APIs is required. I've made the migration(which is a major change) and it will be available with the new release. I think let's try it in new version which is coming soon and see if this issue persists.

Thanks

AmolGangadhare commented 4 years ago

V1.0.0 has been released

closing this, please feel free to reopen this if the issue persists

AhmedTawfiqM commented 1 year ago

Had u find a solution to this issue ?