Android Studio Manifest - 意图过滤器问题
Android Studio Manifest - intent filter problem
因为我想用一些动画启动我的应用程序。我需要先开始动画 activity。 SplashActivity 是动画 activity.
在清单中我试过这个:
<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>
但是我得到了这个错误:
A failure occurred while executing
com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
Android resource linking failed
ERROR:/Users/kalilux/AndroidStudioProjects/NumberGuessingApp/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:25:
AAPT: error: unexpected element found in .
第 25 行是哪里。
感谢您发布所有清单代码。用 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>
</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>
因为我想用一些动画启动我的应用程序。我需要先开始动画 activity。 SplashActivity 是动画 activity.
在清单中我试过这个:
<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>
但是我得到了这个错误:
A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction Android resource linking failed ERROR:/Users/kalilux/AndroidStudioProjects/NumberGuessingApp/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:25: AAPT: error: unexpected element found in .
第 25 行是哪里。
感谢您发布所有清单代码。用 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>