错误记录Android 应用中启动 FlutterActivity 报错 ( have you declared this activity in your AndroidManifest )(代码片

Posted 韩曙亮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误记录Android 应用中启动 FlutterActivity 报错 ( have you declared this activity in your AndroidManifest )(代码片相关的知识,希望对你有一定的参考价值。





一、报错信息



在 Android 中启动 FlutterActivity 报错 : android 应用调用 Flutter 应用界面 ;

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.flutter_native, PID: 12994
    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.flutter_native/io.flutter.embedding.android.FlutterActivity}; have you declared this activity in your AndroidManifest.xml?
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2118)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1746)
        at android.app.Activity.startActivityForResult(Activity.java:5412)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:597)
        at android.app.Activity.startActivityForResult(Activity.java:5337)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:583)
        at android.app.Activity.startActivity(Activity.java:5819)
        at android.app.Activity.startActivity(Activity.java:5787)
        at com.example.flutter_native.MainActivity$2.onClick(MainActivity.java:33)
        at android.view.View.performClick(View.java:7316)
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
        at android.view.View.performClickInternal(View.java:7290)
        at android.view.View.access$3600(View.java:838)
        at android.view.View$PerformClick.run(View.java:28262)
        at android.os.Handler.handleCallback(Handler.java:900)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8668)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)





二、报错信息



在 AndroidManifest.xml 中配置 FlutterActivity :

<activity
    android:name="io.flutter.embedding.android.FlutterActivity"
    android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
    android:hardwareAccelerated="true"
    android:windowSoftInputMode="adjustResize" />

完整的 AndroidManifest.xml 清单文件配置如下 :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.flutter_native">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Flutter_native">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="io.flutter.embedding.android.FlutterActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize" />
    </application>

</manifest>

以上是关于错误记录Android 应用中启动 FlutterActivity 报错 ( have you declared this activity in your AndroidManifest )(代码片的主要内容,如果未能解决你的问题,请参考以下文章

将应用程序从 Android Studio 部署到 iPhone 时出现 Flutter 错误

错误记录Android 应用安装后出现两个启动图标 ( 排查应用及依赖库中配置了 android.intent.category.LAUNCHER 的 Activity )

错误记录Android 应用安装后出现两个启动图标 ( 排查应用及依赖库中配置了 android.intent.category.LAUNCHER 的 Activity )

错误记录Flutter 混合开发报错 ( Android 端与 Flutter 端 EventChannel 初始化顺序错误导致无法通信 | EventChannel 通信流程 )

您好,我正在尝试为 Flutter 设置我的 Android 设备。梯度错误

Flutter 应用程序在 Android 模拟器上运行,但不在物理设备上(OnePlus 7T)