我已经将模拟器版本和Android SDK版本更新到Android S (Android 12)。更新后,我无法运行项目。我不能运行Hello, World!项目(空项目),但我可以建立Gradle以及,但我不能运行项目。我总是得到错误:
Manifest合并失败:针对Android 12及更高版本的应用程序失败
需要为android指定一个显式值:当
相应的组件定义了一个意图过滤器。看到
https://developer.android.com/guide/topics/manifest/activity-element#exported
获取详细信息。
我该怎么解决呢?
以下是截图:
使用Android 12 SDK时如何解决此问题?
这个问题是应用这个问题的解决方案之后的问题,和这个问题不一样。而且,这个问题比这个更古老。
针对Android 12的应用
将应用程序的targetSdkVersion更改为S(32或31)以启用新行为。
然后将Manifest中的android:exported=""属性指定为true或false,具体取决于Activity。
对于启动器活动,如splash或MainActivity,使用android:exported="true",对于其余的活动,使用android:exported="false"
例如:
<!-- It's **true** for the launcher Activity -->
<activity android:name=".SplashActivity"
android:exported="true" />
<!-- It's **false** for the rest of the Activities -->
<activity android:name=".MainActivity"
android:exported="false" />