赞
踩
在 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>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。