前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【错误记录】Android 应用中启动 FlutterActivity 报错 ( have you declared this activity in your AndroidManifest )

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

作者头像
韩曙亮
发布2023-03-29 15:51:02
6040
发布2023-03-29 15:51:02
举报
文章被收录于专栏:韩曙亮的移动开发专栏

文章目录

一、报错信息


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

代码语言:javascript
复制
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 :

代码语言:javascript
复制
<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 清单文件配置如下 :

代码语言:javascript
复制
<?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>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-08-27,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章目录
  • 一、报错信息
  • 二、报错信息
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档