Describe the bug
Running the Android example causes a ClassCastException.
To Reproduce
Steps to reproduce the behavior:
Clone the project
Run flutter run on an Android device
See error
Expected behavior
Android app should start.
Screenshots
N/A.
Logs
E/AndroidRuntime(28799): FATAL EXCEPTION: main
E/AndroidRuntime(28799): Process: de.mintware.example, PID: 28799
E/AndroidRuntime(28799): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{de.mintware.example/android.app.Application}: java.lang.ClassCastException: android.app.Application cannot be cast to android.app.Activity
E/AndroidRuntime(28799): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4047)
E/AndroidRuntime(28799): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4322)
E/AndroidRuntime(28799): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
E/AndroidRuntime(28799): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
E/AndroidRuntime(28799): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
E/AndroidRuntime(28799): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685)
E/AndroidRuntime(28799): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(28799): at android.os.Looper.loopOnce(Looper.java:230)
E/AndroidRuntime(28799): at android.os.Looper.loop(Looper.java:319)
E/AndroidRuntime(28799): at android.app.ActivityThread.main(ActivityThread.java:8919)
E/AndroidRuntime(28799): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(28799): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
E/AndroidRuntime(28799): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
E/AndroidRuntime(28799): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to android.app.Activity
E/AndroidRuntime(28799): at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
E/AndroidRuntime(28799): at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:44)
E/AndroidRuntime(28799): at android.app.Instrumentation.newActivity(Instrumentation.java:1378)
E/AndroidRuntime(28799): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4034)
E/AndroidRuntime(28799): ... 12 more
Environment (please complete the following information):
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index b14b12f..b320208 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.mintware.example">
- <application android:label="example" android:icon="@mipmap/ic_launcher">
- <activity android:name="${applicationName}" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
+ <application android:name="${applicationName}" android:label="example" android:icon="@mipmap/ic_launcher">
+ <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Describe the bug Running the Android example causes a ClassCastException.
To Reproduce Steps to reproduce the behavior:
flutter run
on an Android deviceExpected behavior Android app should start.
Screenshots N/A.
Logs
Environment (please complete the following information):
barcode_scan
flutter --version
:Additional context This commit broke it: https://github.com/mono0926/barcode_scan2/commit/c589b6feee5434b1b4d71f565c4abb12dfd347c2 as
android:name="${applicationName}"
should be an attribute of<application>
, not<activity>
.The correct syntax is: