活动初始屏幕未在 Android 清单中声明



我在尝试运行我的应用程序时不断收到错误,说......活动 SplashScreen 未在 Android 清单中声明.xml

任何想法,因为它让我发疯! :-(

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sjmplanningfinal">
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@android:style/Theme.Holo.Light">
<activity android:name="com.example.sjmplanningfinal.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.sjmplanningfinal.SJMPlanningHome" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sjmplanningfinal">
<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="@android:style/Theme.Holo.Light">
<activity android:name="com.example.sjmplanningfinal.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.sjmplanningfinal.SJMPlanningHome" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter> </application>
</manifest>

从 SJMPlanningHome 中删除标签action android:name="android.intent.action.MAIN。您已将两个活动声明为主活动。

每个Android应用程序都应该在清单中定义"application"标签..作为主标签,然后在应用程序内部定义活动。这是清单的结构:您也可以在这里检查:清单结构

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<uses-permission />
<permission />
<permission-tree />
<permission-group />
<instrumentation />
<uses-sdk />
<uses-configuration />
<uses-feature />
<supports-screens />
<compatible-screens />
<supports-gl-texture />
<application>
<activity>
<intent-filter>
<action />
<category />
<data />
</intent-filter>
<meta-data />
</activity>
</application>
</manifest>

首先,您缺少application标签。你必须把标签放在前面

android:allowBackup="true"

和之后

<activity android:name="com.example.sjmplanningfinal.SJMPlanningHome">

其次,您忘记在过滤意图后关闭activitySJMPlanningHome

这是完整的代码。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sjmplanningfinal">
<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="@android:style/Theme.Holo.Light">
<activity android:name="com.example.sjmplanningfinal.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.sjmplanningfinal.SJMPlanningHome">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>

最新更新