【[RK3288][Android6.0] 调试笔记 --- 替换系统签名】古人已用三冬足,年少今开万卷余。这篇文章主要讲述[RK3288][Android6.0] 调试笔记 --- 替换系统签名相关的知识,希望能为你提供帮助。
本文转载自:http://blog.csdn.net/kris_fei/article/details/55100299
Platform: RK3288
OS: android 6.0
Kernel: 3.10.92
由于项目的apk安装需要shareid为system的权限(不需要高权限的apk是可以正常安装的),
一开始我用的是releasekey,导致签名文件不匹配无法安装,因此就替换系统默认platform签名文件.
生成新的签名文件
方法参考rk3288/build/target/product/security/README
[[email
protected]:~/rk3288]$./development/tools/make_key platform ‘/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email
protected]‘
后面参数可自行修改,参见:
http://blog.csdn.net/jscese/article/details/24243171
会生成两种文件:
公钥: platform.x509.pem
私钥: platform.pk8
系统端修改:
不管编译版本(项目需求),都改成platform签名文件.
build/core/Makefile:
ifeq ($(TARGET_BUILD_VARIANT),user)
BUILD_KEYS := release-keys
endif
#Kris, 170214, use our platform key.
+ BUILD_KEYS := platform-keys
build/core/config.mk:
# The default key if not set as LOCAL_CERTIFICATE
ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
else
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
endif
#Kris, 170214, use our platform key.
+ DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/platform
这样build systemimage就会用名字为platform的签名文件.
APK端:
这里拿Music app作测试.
[[email
protected]:~/rk3288/packages/apps/Music]$ g df
diff --git a/Android.mk b/Android.mk
index d2b7691..c6aa64c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -7,7 +7,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) \
src/com/android/music/IMediaPlaybackService.aidl
LOCAL_PACKAGE_NAME := Music
-
+LOCAL_CERTIFICATE := platform
LOCAL_SDK_VERSION := current
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2db6259..2dbd79b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -15,7 +15,9 @@
-->
<
manifest xmlns:android="http://schemas.android.com/apk/res/android"
-
package="com.android.music">
+
package="com.android.music"
+
coreApp="true"
+
android:sharedUserId="android.uid.system">
<
original-package android:name="com.android.music" />
<
uses-sdk android:minSdkVersion="8" android:targetSdkVersion="9"/>
如果没定义LOCAL_CERTIFICATE, 或者LOCAL_CERTIFICATE的签名和系统签名不一致,安装会不成功,有如下提示:
[[email
protected]:~/rk3288/out/target/product/rk3288/system/app/Music]$ adb install Music.apk
4318 KB/s (904296 bytes in 0.204s)
pkg: /data/local/tmp/Music.apk
Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE]
logcat中会有:
01-21 14:51:37.101
2215
2215 D AndroidRuntime: Calling main entry com.android.commands.pm.Pm
01-21 14:51:37.160
2175
2188 D DefContainer: Copying /data/local/tmp/Music.apk to base.apk
01-21 14:51:37.677
517
572 W PackageManager:
Package com.android.music signatures do not match the previously installed version;
ignoring!
参考:
http://blog.csdn.net/jscese/article/details/24243171
http://blog.csdn.net/jimbo_lee/article/details/39183831
http://blog.csdn.net/jingwen3699/article/details/8024900
http://blog.csdn.net/jiangwei0910410003/article/details/51316688
推荐阅读
- 知识点干货--聊一聊Android中Service与Thread的区别
- 用PS制作APP的界面图片
- C#(进程线程应用程序域(AppDomain)与上下文分析)
- 基于androidstudio3.0的build文件配置问题
- cocos3.x实现android沉浸式模式(全屏,隐藏导航栏即虚拟键)
- Android资源文件手记
- mac本地如何搭建IPv6环境测试你的APP
- 自建APP,选择哪家公司比较靠谱?
- APP产品的分析定位