我已经将模拟器版本和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时如何解决此问题?

这个问题是应用这个问题的解决方案之后的问题,和这个问题不一样。而且,这个问题比这个更古老。


当前回答

这将对2021年的用户有所帮助。

在你的两个构造中的一个。gradle文件,你应该能够找到行targetSDK 31。把它改为30,然后做一个gradle同步(在主代码窗口上方会出现一个小栏,你可以点击“现在同步”),你应该可以开始了。

其他回答

在我的项目瞄准Android 12后,我也遇到了同样的问题。

问题是这个项目非常大,有多个AndroidManifest.xml文件,而且android:exported在很多地方都不见了。

我最终创建了一个Gradle任务来填补缺失的android:为我自动导出属性。

这里是链接。

更新androidTestImplementation 'androidx.test.ext:junit:1.1.1'到最新版本,如下:

androidtestimplemimplementation ` androidx.test.ext:junit:1.1.3'从构建。Gradle应用级别。

你需要指定android:exported="false"或android:exported="true"

清单:

<activity
    android:name=".MainActivity"
    android:exported="true"
    android:theme="@style/Theme.MyApplication.NoActionBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

如文件所述:

如果您的应用程序针对Android 12,并包含活动,服务,或 广播接收器使用意图过滤器,你必须显式 为这些应用组件声明android: exported属性。

警告:如果活动、服务或广播接收器使用intent 的过滤器,并且没有显式声明的值 Android:导出,您的应用程序不能安装在运行的设备上 Android 12。

还要检查何时为'android:exported'值使用true/false。

添加android:出口= " true ":

<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions"/>
    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher"/>
    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"
     android:exported="true">

        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
        </intent-filter>
    </receiver>

你的问题可能被标记为重复,因为这篇文章:针对Android 12的Manifest合并失败,尽管你的文章是在一周前发布的。我现在看不到国旗了。

为了澄清另一个答案,请注意,android:exported应该为你的主活动设置为true,否则它将不会启动,尽管android Studio有鼓励的“启动成功”消息,因为没有其他应用程序,甚至android系统本身,可以启动它。

<activity
    android:name=".MainActivity"
    android:exported="true"

对于其他意图隐藏在合并清单中的活动,这通常会被设置为false。