【错误记录】Manifest 清单文件报错 ( ..required to specify an explicit value for `android:exported` when the .. )
2023-06-13 09:18:01 时间
文章目录
一、报错信息
修改 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.android.com/guide/topics/manifest/activity-element#exported
for details. AD_ID_Test.app main manifest (this file)
二、解决方案
这是 Android 12 的行为变更中的一条 , 参考 行为变更:以 Android 12 为目标平台的应用 官方文档 ;
在每个组件上添加
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"/>
<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>
修改后的清单文件 :
<?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 清单文件合并成功 ;
相关文章
- Android浏览器多窗口webview界面截屏心得「建议收藏」
- android 的hook技术,Android Native Hook技术(一)
- 自己动手用Android和Xposed编写一个微信聊天机器人——《微信聊天精灵》实现关键词自动回复。
- android 读取本地数据库db文件(Android sqlite)
- android scaleanimation动画,Android 的ScaleAnimation 缩放动画基本运用
- android 复制控件,Android长按复制文本功能[通俗易懂]
- android studio 导入第三方库的记录
- 【Android NDK 开发】JNI 动态注册 ( 动态注册流程 | JNI_OnLoad 方法 | JNINativeMethod 结构体 | GetEnv | RegisterNatives )
- 【错误记录】p7zip 交叉编译 Android 版本 NDK 报错 ( Application.mk | APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 )
- 【错误记录】Android 文件查看错误 ( Error opening contents of device file ““: Cannot create directory )
- 【错误记录】Android Studio Logcat 报错 ( read: unexpected EOF! )
- 【错误记录】Android 应用运行报错 ( You need to use a Theme.AppCompat theme (or descendant) with this activity. )
- 【错误记录】Android Studio 编译报错 ( Invalid main APK outputs : EarlySyncBuildOutput )
- 【错误记录】Android Studio 向 GitHub 提交代码报错 ( Push failed: Failed with error: Could not read | 使用命令行提交代码 )
- 【Android 逆向】启动 DEX 字节码中的 Activity 组件 ( 在 PathClassLoader 和 BootClassLoader 之间插入 DexClassLoader )
- 【错误记录】Android Studio 编译报错 ( Could not install Gradle distribution from ‘https://services.gradle.or )
- 【错误记录】Android 应用安装后出现两个启动图标 ( 排查应用及依赖库中配置了 android.intent.category.LAUNCHER 的 Activity )
- 【Android Gradle 插件】ProductFlavor 配置 ( multiDexEnabled 配置 | multiDexKeepFile | multiDexKeepProguard )
- 【错误记录】未安装该应用 ( 在 Android 12 之后 组件设置 android:exported=“false“ 属性 )
- 【错误记录】编译 Android 版本的 ijkplayer 报错 ( ./init-android.sh: 第 37 行: cd: android/contrib/: 没有那个文件或目录 )
- 【ijkplayer】编译 Android 版本的 ijkplayer ③ ( 执行 compile-ffmpeg.sh clean 命令 | 下载并配置 android-ndk-r10e )
- 【错误记录】Android Studio 编译时 lint 检查报错 ( Error: Google Play requires that apps target API level 29 or )
- 【错误记录】Android Studio 打包 apk 文件报错 ( The destination folder does not exist or is not writeable )
- 【错误记录】Android Studio 编译报错 ( The minCompileSdk (33) specified in a dependency‘s AAR metadata META-I )
- Android中SQLite数据操作详解手机开发
- [android] 保存文件到SD卡详解手机开发
- Android Studio 导入项目 出现安装Error:Cause: failed to find target with hash string ‘android-23’ 等错误详解手机开发
- android实现程序自动升级到安装示例分享(下载android程序安装包)