com.package.MainActivity cannot be cast to io.flutter.embedding.android.FlutterActivity
See original GitHub issueBecause 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)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:16
Top Results From Across the Web
com.deliveryrunner.vendor.MainActivity cannot be cast to ...
and it worked fine back then. Here is the old Application file : package com.deliveryrunner.vendor; import io.flutter.app.
Read more >Supporting the new Android plugins APIs | Flutter
The following instructions outline the steps for supporting the new API: ... package io.flutter.plugins.firebasecoreexample; import io.flutter.embedding.android.
Read more >Fix Application crash Error “android.app.Application cannot be ...
FATAL EXCEPTION, Fix Application crash Error “ android.app.Application cannot be cast to”#FataException #RuntimeException #JavaException.
Read more >Native | Flutter - Google Developers
package my.app.path; import io.flutter.embedding.android.FlutterActivity; import io.flutter.embedding.engine.FlutterEngine;
Read more >Firebase – java.lang.RuntimeException - flutter - iTecNote
RuntimeException: Unable to instantiate activity in Flutter ... MainActivity cannot be cast to android.app. ... import 'package:flutter/material.dart'; ...
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
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