清单合并失败:即使我的 AndroidManifest.xml 文件中没有服务,也需要为 <service> 显式指定 android:exported

iDe*_*ode 12 android android-studio

清单合并失败:需要显式指定 android:exported 。android:exported当相应组件定义了意图过滤器时,面向 Android 12 及更高版本的应用需要指定显式值。有关详细信息,请参阅https://developer.android.com/guide/topics/manifest/activity-element#exported 。

<services我的应用程序的文件中没有AndroidManifest.xml,我也查找了每个AndroidManifest.xml文件,它们也没有任何<service元素,那么为什么我会收到此错误?

我的合并清单选项卡中没有错误,但是,第一个清单有两个,<receiver并且我已经android:exported在其中手动添加了属性。

在此输入图像描述

小智 9

app-> src-> main->中,您需要显式添加每个下AndroidManifest.xml的标签android:exported="true"<Activity><Application>

<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="@style/Theme.Eynetic">
    <activity android:name=".Splash_Screen"
        android:theme="@style/SplashTheme"
        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=".MainActivity"
        android:theme="@style/MainTheme"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
Run Code Online (Sandbox Code Playgroud)

请参阅代码中的活动标签...

<activity android:name=".Splash_Screen"
        android:theme="@style/SplashTheme"
        android:exported="true">
Run Code Online (Sandbox Code Playgroud)

目前我正在对每个活动执行此操作,因为这是 Android studio 给出的错误,但也许有更好的方法可以在代码中的某处仅添加一次。


Ven*_*nky 1

尝试在您自己的清单文件中添加android:exported = falseprandroid:exported = true并编译代码。我希望这能解决您的问题。因为在通知中手动添加将不起作用。