一、報錯信息
修改 AndroidManifest.xml 清單文件時 , 發(fā)現(xiàn)合并清單文件時報錯 , 該報錯不影響程序運行 ; 報錯信息 : 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 為目標平臺的應(yīng)用 官方文檔 ; 
在每個組件上添加 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 清單文件合并成功 ; 
|