我们在进行Android开发的时候,如果开发的是系统应用,都需要系统的签名才能正常运行。而系统应用一般是把代码统一放到系统代码库中跟随系统一起编译。而如果我们想用Android Studio单独开发某个应用而使用系统签名的时候,有两种开发的方式,一种是编译完成后,使用SignApk.jar来进行签名,另外一种是把系统的 platform.x509.pemplatform.pk8 转换成为Android Studio常用的 .keystore文件,编译时候自动签名。
Android系统签名证书的目录是“build/target/product/security”。
SignApk.jar签名
命令行中使用 SignApk.jar签名的方式如下:
转换为 .keystore文件
使用keytool-importkeypair(本站下载)进行转换,转换命令如下:
Android Studio中使用证书:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
signingConfigs
{
release
{
File
strFile
=
new
File
(
"../app/keystore/platform.keystore"
)
storeFile
file
(
strFile
)
keyAlias
'platform'
keyPassword
'android'
storePassword
'android'
}
debug
{
File
strFile
=
new
File
(
"../app/keystore/platform.keystore"
)
storeFile
file
(
strFile
)
keyAlias
'platform'
keyPassword
'android'
storePassword
'android'
}
}
buildTypes
{
release
{
signingConfig
signingConfigs
.
release
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
)
,
'proguard-rules.pro'
}
debug
{
signingConfig
signingConfigs
.
debug
}
}
|
http://www.mobibrw.com/2015/2826