1,创建签名文件
1.1 提取系统签名文件
mkdir signed
cp workspace/aosp/android-11.0.0_r40/build/target/product/security/platform.pk8 signed/
cp workspace/aosp/android-11.0.0_r40/build/target/product/security/platform.x509.pem signed/
cd signed
1.2 生成platform.pem
openssl pkcs8 -inform DER -nocrypt -in platform.pk8 -out platform.pem
1.3 生成platform.p12
openssl pkcs12 -export -in platform.x509.pem -out platform.p12 -inkey platform.pem -password pass:android -name platform
1.4 生成platform.jks
keytool -importkeystore -deststorepass android -destkeystore platform.jks -srckeystore platform.p12 -srcstoretype PKCS12 -srcstorepass android
2,使用签名文件
修改app目录下的build.gradle,添加签名配置
signingConfigs {
defaultSign {
storeFile file("../android11.jks") //签名文件路径
storePassword "android"
keyAlias "platform"
keyPassword "android"
}
}
buildTypes {
release {
//是否混淆
minifyEnabled false
//是否移除无用资源
zipAlignEnabled true
//混淆的配置文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.defaultSign
}
debug {
signingConfig signingConfigs.defaultSign
}
}