分享

【错误记录】Manifest 清单文件报错 ( ..required to specify an explicit value for `android:exported` when the .. )

 hncdman 2022-08-04 发布于湖南
  •  一、报错信息

  •  二、解决方案

一、报错信息


修改 AndroidManifest.xml 清单文件时 , 发现合并清单文件时报错 , 该报错不影响程序运行 ;

报错信息 :

Merging Errors:
Error:
Apps targeting Android 12 and higher are required to specify an explicit
value for `android:exported` when the corresponding component has an
intent filter defined.
See https://developer./guide/topics/manifest/activity-element#exported
for details. AD_ID_Test.app main manifest (this file)

  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

【错误记录】Manifest 清单文件报错 ( ..required to specify an explicit value for `android:exported` when the .. )_Manifest

二、解决方案


这是 Android 12 的行为变更中的一条 , 参考  行为变更:以 Android 12 为目标平台的应用 官方文档 ;

【错误记录】Manifest 清单文件报错 ( ..required to specify an explicit value for `android:exported` when the .. )_android studio_02

在每个组件上添加

android:exported="false"1.

约束属性 ;

修改前的清单文件 :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas./apk/res/android"
package="com.example.ad_id_test">

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

<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.AD_ID_Test">

<meta-data android:name="student" android:value="${name}" />

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>

  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

  • 12.

  • 13.

  • 14.

  • 15.

  • 16.

  • 17.

  • 18.

  • 19.

  • 20.

  • 21.

  • 22.

  • 23.

  • 24.

  • 25.

  • 26.

修改后的清单文件 :

登录后复制 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas./apk/res/android"
package="com.example.ad_id_test">

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

<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.AD_ID_Test">

<meta-data android:name="student" android:value="${name}" />

<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>

  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

  • 12.

  • 13.

  • 14.

  • 15.

  • 16.

  • 17.

  • 18.

  • 19.

  • 20.

  • 21.

  • 22.

  • 23.

  • 24.

  • 25.

  • 26.

  • 27.

修改点 :

【错误记录】Manifest 清单文件报错 ( ..required to specify an explicit value for `android:exported` when the .. )_Manifest_03

添加完毕之后 , 报错消失 , Manifest 清单文件合并成功 ;

【错误记录】Manifest 清单文件报错 ( ..required to specify an explicit value for `android:exported` when the .. )_android studio_04

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多