首页 > 解决方案 > Android Studio Manifest - 意图过滤器问题

问题描述

因为我想用一些动画来启动我的应用程序。我需要先开始动画活动。SplashActivity 是动画活动。

在清单中我试过这个:

   <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.company.numberguessingapp"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk
        android:minSdkVersion="21"
        android:targetSdkVersion="31" />

    <application
        android:allowBackup="true"
        android:appComponentFactory="androidx.core.app.CoreComponentFactory"
        android:debuggable="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:testOnly="true"
        android:theme="@style/Theme.NumberGuessingApp" >
        <activity
            android:name="com.company.numberguessingapp.SplashActivity"
            android:exported="true" /> 
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <activity
            android:name="com.company.numberguessingapp.MainActivity"
            android:exported="true" >
        </activity>
    </application>
</manifest>

但我得到了这个错误:

执行 com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction 时发生故障 Android 资源链接失败 ERROR:/Users/kalilux/AndroidStudioProjects/NumberGuessingApp/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:25 :AAPT:错误:在 中发现意外元素。

第 25 行是在哪里。

标签: androidandroid-studioandroid-manifest

解决方案


感谢您发布所有清单代码。关闭活动标签时确实存在错误intent-filter

你应该输入

<activity
    android:name="com.company.numberguessingapp.SplashActivity"
    android:exported="true"> 
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

代替

<activity
    android:name="com.company.numberguessingapp.SplashActivity"
    android:exported="true" /> 
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

推荐阅读