前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【错误记录】Manifest 清单文件报错 ( ..required to specify an explicit value for `android:exported` when the .. )

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

作者头像
韩曙亮
发布2023-03-30 13:15:23
4600
发布2023-03-30 13:15:23
举报

文章目录

一、报错信息


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

报错信息 :

代码语言:javascript
复制
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 为目标平台的应用 官方文档 ;

在这里插入图片描述
在这里插入图片描述

在每个组件上添加

代码语言:javascript
复制
android:exported="false"

约束属性 ;

修改前的清单文件 :

代码语言:javascript
复制
<?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"/>

    <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>

修改后的清单文件 :

代码语言:javascript
复制
<?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"/>

    <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>

修改点 :

在这里插入图片描述
在这里插入图片描述

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

在这里插入图片描述
在这里插入图片描述
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-03-18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章目录
  • 一、报错信息
  • 二、解决方案
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档