一、报错信息
修改 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)

二、解决方案
这是 Android 12 的行为变更中的一条 , 参考 行为变更:以 Android 12 为目标平台的应用 官方文档 ; 
在每个组件上添加 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 清单文件合并成功 ; 
|