flutter_barcode_scanner: com.package.MainActivity cannot be cast to io.flutter.embedding.android.FlutterActivity
Because of some of my Plugins, i have to use FlutterFragmentActivity instead of FlutterActivity.
Unfortunately the Plugin is not working then.
Error:
E/AndroidRuntime(18103): java.lang.ClassCastException: de.fitasy.MainActivity cannot be cast to io.flutter.embedding.android.FlutterActivity
E/AndroidRuntime(18103): at com.amolg.flutterbarcodescanner.FlutterBarcodeScannerPlugin.createPluginSetup(FlutterBarcodeScannerPlugin.java:248)
E/AndroidRuntime(18103): at com.amolg.flutterbarcodescanner.FlutterBarcodeScannerPlugin.onAttachedToActivity(FlutterBarcodeScannerPlugin.java:275)
E/AndroidRuntime(18103): at io.flutter.embedding.engine.FlutterEnginePluginRegistry.add(FlutterEnginePluginRegistry.java:143)
E/AndroidRuntime(18103): at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:26)
E/AndroidRuntime(18103): at de.fitasy.MainActivity.configureFlutterEngine(MainActivity.kt:10)
E/AndroidRuntime(18103): at io.flutter.embedding.android.FlutterFragment.configureFlutterEngine(FlutterFragment.java:950)
E/AndroidRuntime(18103): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:181)
E/AndroidRuntime(18103): at io.flutter.embedding.android.FlutterFragment.onAttach(FlutterFragment.java:582)
E/AndroidRuntime(18103): at androidx.fragment.app.Fragment.performAttach(Fragment.java:2574)
E/AndroidRuntime(18103): at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:828)
E/AndroidRuntime(18103): at androidx.fragment.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1197)
E/AndroidRuntime(18103): at androidx.fragment.app.FragmentTransition.calculateFragments(FragmentTransition.java:1080)
E/AndroidRuntime(18103): at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:119)
E/AndroidRuntime(18103): at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1866)
E/AndroidRuntime(18103): at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 11
- Comments: 16
Commits related to this issue
- Added support for official local_auth flutter plugin This issue was mentioned here and this is the solution. https://github.com/AmolGangadhare/flutter_barcode_scanner/issues/128#issue-720309668 — committed to TylerByte666/flutter_barcode_scanner by TylerByte666 3 years ago
- Added support for official local_auth flutter plugin This issue was mentioned here and this is the solution. https://github.com/AmolGangadhare/flutter_barcode_scanner/issues/128#issue-720309668 — committed to phr34k/flutter_barcode_scanner by TylerByte666 3 years ago
- Add Flutter Barcode Scanner plugin and update FlutterActivity -> FlutterFragmentActivity. https://github.com/AmolGangadhare/flutter_barcode_scanner/issues/128 — committed to nr23730/nc-passwords-app by joleaf 3 years ago
- Added support for official local_auth flutter plugin This issue was mentioned here and this is the solution. https://github.com/AmolGangadhare/flutter_barcode_scanner/issues/128#issue-720309668 — committed to bugsburny2/flutter_barcode_scanner by TylerByte666 3 years ago
In file FlutterBarcodeScannerPlugin.java
I’ve modified all reference to
FlutterActivity
toFlutterFragmentActivity
and now it works.This is a workaround that works for me.
.pub-cache/hosted/pub.dartlang.org/flutter_barcode_scanner-2.0.0/android/src/main/java/com/amolg/flutterbarcodescanner