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 455 forks source link

App Crashing After Adding Library! #122

Closed Akash136 closed 3 years ago

Akash136 commented 4 years ago

I want to use qrcode scanner in my app but when i included this library in pubsec.yaml and restarted my app its startcrashing before and following is my Log! Please Revert As Soon As Possible!

E/AndroidRuntime(32202): FATAL EXCEPTION: main
E/AndroidRuntime(32202): Process: com.siliconleaf.thegrocerstore, PID: 32202
E/AndroidRuntime(32202): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.siliconleaf.thegrocerstore/com.siliconleaf.thegrocerstore.MainActivity}: java.lang.ClassCastException: com.siliconleaf.thegrocerstore.MainActivity cannot be cast to io.flutter.embedding.android.FlutterActivity
E/AndroidRuntime(32202):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
E/AndroidRuntime(32202):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3961)
E/AndroidRuntime(32202):    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
E/AndroidRuntime(32202):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
E/AndroidRuntime(32202):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
E/AndroidRuntime(32202):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2386)
E/AndroidRuntime(32202):    at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(32202):    at android.os.Looper.loop(Looper.java:213)
E/AndroidRuntime(32202):    at android.app.ActivityThread.main(ActivityThread.java:8178)
E/AndroidRuntime(32202):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(32202):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
E/AndroidRuntime(32202):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
E/AndroidRuntime(32202): Caused by: java.lang.ClassCastException: com.siliconleaf.thegrocerstore.MainActivity cannot be cast to io.flutter.embedding.android.FlutterActivity
E/AndroidRuntime(32202):    at com.amolg.flutterbarcodescanner.FlutterBarcodeScannerPlugin.registerWith(FlutterBarcodeScannerPlugin.java:87)
E/AndroidRuntime(32202):    at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:58)
E/AndroidRuntime(32202):    at com.siliconleaf.thegrocerstore.MainActivity.onCreate(MainActivity.kt:11)
E/AndroidRuntime(32202):    at android.app.Activity.performCreate(Activity.java:8086)
E/AndroidRuntime(32202):    at android.app.Activity.performCreate(Activity.java:8074)
E/AndroidRuntime(32202):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1313)
E/AndroidRuntime(32202):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3755)
E/AndroidRuntime(32202):    ... 11 more
yashrajsharma23 commented 3 years ago

I am facing the same issue can someone please help us out? I have added updated library version ^1.0.0 it give same above classcastexception in my flutterActivity as below,

 Caused by: java.lang.ClassCastException: com.example.flutter_app.MainActivity cannot be cast to io.flutter.embedding.android.FlutterActivity
    at com.amolg.flutterbarcodescanner.FlutterBarcodeScannerPlugin.registerWith(FlutterBarcodeScannerPlugin.java:87)
    at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:48)

GeneratedPluginRegistrant.java: 48 : FlutterBarcodeScannerPlugin.registerWith(registry.registrarFor("com.amolg.flutterbarcodescanner.FlutterBarcodeScannerPlugin"));

But everything works fine when I downgrade the library(as in ^0.1.5+2) to below 1.0.0 version then I didn't face any such crashing which I don't prefer to downgrade the library. Thanks in advance.

MohamedYousof commented 3 years ago

same here

kmadisa commented 3 years ago

I followed these instructions https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects and it solved that problem.

AmolGangadhare commented 3 years ago

Is anyone still facing this issue?

This can be resolved by upgrading the flutter.

If possible please update that the issue is fixed or not as I'm unable to reproduce this one, if this issue persists so this can be taken into high priority.

Thanks

rktvsiim commented 3 years ago

I followed these instructions https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects and it solved that problem.

Thanks! This guide solved it for me as well!

AmolGangadhare commented 3 years ago

With Flutter 2.0 and flutter_barcode_scanner : 2.0.0 this wont be there.

Closing this now, feel free to open a new issue.