IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 移动开发 -> 【Android S】【GMS Requirements】Valid V2+ signature for preloaded APKs -> 正文阅读

[移动开发]【Android S】【GMS Requirements】Valid V2+ signature for preloaded APKs

作者:recommend-item-box type_blog clearfix

Google要求:

13.3.5 Valid V2+ signature for preloaded APKs

[GMS-13.3.5-001]?For PRODUCTs that launch with or upgrade to Android 11 or higher, if a preloaded APK file targets API level 30 or higher, it MUST be signed and verifiable with the APK Signature scheme v2 or higher. Any native libraries embedded in it MUST be uncompressed and page aligned before signing.

See?Valid V2+ signature guide?for more details about how to uncompress JNI libs and dex files and impact on the devices.

【解读】

凡是预置的API level>= 30的任何APK必须满足如下要求:
1. 必须使用V2+ signatures
2.apk中不要存在被压缩的JNI libs(.so)或 Dex 文件,如果压缩需要按照要求配置修改,否则将导致这类apk无法使用
此项要求从2021年10月1日起, 通过GTS 9.0 R1(GtsJniUncompressHostTest)开始检查,不满足则存在GTS fail 。
适用对象:
?针对Android R(11)及以上的所有项目(包括升级项目),以及所有的Build (IR/LR/MR/SMR)上预置的API level>= 30的任何APK
检查方法:
V2+签名的应用校验步骤:
1.确认apklevel是否为>=30,如>=30则走2
aapt dump badging 拖进apk |findstr targetSdkVersion
2.确认APK签名,必须为V2+,如果不是V2+签名则 apk必须整改
java -jar apksigner.jar verify -verbose -print-certs??拖进apk
3.确认apk中的JNI so和dex是否被压缩:
unzip -v E:\APK\aida64-v178.apk lib/*.so?
unzip -v E:\APK\aida64-v178.apk *.dex
如果存在.so/.dex压缩,则必须使用:LOCAL_REPLACE_PREBUILT_APK_INSTALLED 编译apk,不要使用copy命令!
示例代码如下:
示例?
?include $(CLEAR_VARS)
LOCAL_MODULE := BrowserHeytapProdOv
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_MODULE_PATH := $(TARGET_OUT)/app/
LOCAL_REPLACE_PREBUILT_APK_INSTALLED := $(LOCAL_PATH)/Browser_45.7.5.9_399635f_7fa16a1_210316_HeytapProdOv.apk
LOCAL_DEX_PREOPT := false
LOCAL_MULTILIB := 32
JNI_LIBS :=
$(foreach FILE,$(shell find $(LOCAL_PATH)/BrowserHeytapProdOv/armeabi-v7a/ -name *.so), $(eval JNI_LIBS += $(FILE)))
LOCAL_PREBUILT_JNI_LIBS := $(subst $(LOCAL_PATH),,$(JNI_LIBS))
include $(BUILD_PREBUILT)
特别说明:禁止使用cp命令拷贝apk、so库,请使用下面属性预置:
预置apk使用属性: LOCAL_REPLACE_PREBUILT_APK_INSTALLED??
预置so库使用属性:LOCAL_PREBUILT_JNI_LIBS?

Google Q&A:

Q:The requirement and What GTS tests

A:Requirements:?The preloaded apk must have a valid V2 or higher signature.

GTS tests if signature of the apk is valid or not. It actually runs the command?apksigner verify --in <YourAPK> -v, which you can run locally and check. (Before and after the build).

GTS does not check if JNI or Dex is compressed or not compressed. The main problem is "Android build system" has to repackage apks if JNI is compressed (and dex is compressed in case of privileged app). This repackages strips the signature. If this signature is stripped then it is not safe and that's why GTS fails.

If 3rd party apk with compressed JNI/Dex with proper signature (not gone through the Android build) are copied to system image, it is FINE. Because their signature will be still proper. In this case, the GTS will pass.

Q:JNI files

A:If apk has compressed JNI, then Android build MUST uncompress them, which will remove the signature. Hence, app Apk going in to Android build, MUST have uncompressed JNIs.

So if you are seeing any GTS failure, you can check unzip -v YourApp.apk 'lib/*.so for the apk before the build. If it has a compressed JNI files, then that is the issue. Those must be uncompressed in the apk.

Q:Dex files

A:It is ONLY applicable to privileged apps only.

If Dex files are compressed in the privilged apk, the build uncompresses them. This removes the signature. There are 2 ways to solve this

  1. Have Dex files uncompressed in the Apk before the build. Then Android build will not change it. There will be no issue

OR

  1. DONT_UNCOMPRESS_PRIV_APPS_DEXS=true. This flag means Android build will not uncompress any dex files. This is an easier way to avoid GTS failures for the DEX files.

Note:?For android build uncompressing Dex file is not mandatory, it is good to uncompresses DEX files but not REQUIRED. By using above flag, uncompression of the dex files can be stopped.

参考Google case ID:https://partnerissuetracker.corp.google.com/issues/202690309

?

  移动开发 最新文章
Vue3装载axios和element-ui
android adb cmd
【xcode】Xcode常用快捷键与技巧
Android开发中的线程池使用
Java 和 Android 的 Base64
Android 测试文字编码格式
微信小程序支付
安卓权限记录
知乎之自动养号
【Android Jetpack】DataStore
上一篇文章      下一篇文章      查看所有文章
加:2021-12-01 17:49:28  更:2021-12-01 17:51:24 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 6:15:47-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码