【错误记录】Manifest 清单文件报错 ( ..required to specify an explicit value for `android:exported` when the .. )
生活随笔
收集整理的這篇文章主要介紹了
【错误记录】Manifest 清单文件报错 ( ..required to specify an explicit value for `android:exported` when the .. )
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
文章目錄
- 一、報(bào)錯(cuò)信息
- 二、解決方案
一、報(bào)錯(cuò)信息
修改 AndroidManifest.xml 清單文件時(shí) , 發(fā)現(xiàn)合并清單文件時(shí)報(bào)錯(cuò) , 該報(bào)錯(cuò)不影響程序運(yùn)行 ;
報(bào)錯(cuò)信息 :
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.android.com/guide/topics/manifest/activity-element#exported for details. AD_ID_Test.app main manifest (this file)二、解決方案
這是 Android 12 的行為變更中的一條 , 參考 行為變更:以 Android 12 為目標(biāo)平臺(tái)的應(yīng)用 官方文檔 ;
在每個(gè)組件上添加
android:exported="false"約束屬性 ;
修改前的清單文件 :
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.ad_id_test"><uses-permission android:name="com.google.android.gms.permission.AD_ID"/><applicationandroid: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>修改后的清單文件 :
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.ad_id_test"><uses-permission android:name="com.google.android.gms.permission.AD_ID"/><applicationandroid: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>修改點(diǎn) :
添加完畢之后 , 報(bào)錯(cuò)消失 , Manifest 清單文件合并成功 ;
總結(jié)
以上是生活随笔為你收集整理的【错误记录】Manifest 清单文件报错 ( ..required to specify an explicit value for `android:exported` when the .. )的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【BLE MIDI】MIDI 时间标志分
- 下一篇: 【Android Gradle 插件】P