一、配置簽名信息 /** * 1.testApplicationId用於配置測試App的包名,預設情況下是applicationId + ".test".一般情況下預設即可,他也是 * ProductFlavor的一個屬性,方法原型為 * public ProductFlavor setTestAp ...
一、配置簽名信息
/**
* 1.testApplicationId用於配置測試App的包名,預設情況下是applicationId + ".test".一般情況下預設即可,他也是
* ProductFlavor的一個屬性,方法原型為
* public ProductFlavor setTestApplicationId(String applicationId) {
* mTestApplicationId = applicationId;
* return this;
* }
*
* public String getApplicatonId() {
* return mTestApplicationId;
* }
*
* 2.testInstrumentationRunner
* 用於配置單元測試使用的Runner,預設使用的是android.test.InstrumenttationTestRunner,
* 如果自定義的Runner,修改這個值就可以,它也是一個屬性,方法原型
* public ProductFlavor setTestInstrument(String testInstrumentationRunner) {
* mTestInstrumentationRunner = testInstrumentationRunner;
* return this;
* }
*
* 3.signingConfig
* 配置磨人的簽名信息,對生成的App簽名,他是一個SigningConfig, 也是ProductFlavor的一個屬性,他可以直接對其進行配置,方法原型為:
* public SigningConfig getSigningConfig() {
* return mSigningConfig;
* }
*
* public ProductFlavor setSigningConfig(SigningConfig signingConfig) {
* mSigningConfig = signingConfig;
* return this;
* }
*
* 4. proguardFile
* 用於配置App ProGuard混淆所使用的ProGuard配置文件,它是ProductFlavor的一個方法,接受一個文件作為參數,其方法原型為:
* public void proguardFile(Object proguardFile) {
* getProguardFiles().add(project.file(proguardFile));
* }
*
* 5.proguardFiles
* 這個也是配置ProGuard的配置文件,只不過他可以同時接受多個配置文件,因為它的參數是一個可變類型的參數
* public void proguardFiles(Object... proguardFileArray) {
* getProguardFiles.addAll(project.files(proguardFileArray).getFiles());
* }
*/
1.使用混淆示例
release {
minifyEnabled false
// 使用混淆功能
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
- minifyEnable表示啟用混淆功能
二、簽名信息
1.一些註意事項
- APP必須簽名才能發佈使用。
- APP被惡意篡改,簽名變動,就無法安裝升級。
- APP有debug和release兩種,debug模式一般AndroidSDK已經為我們提供了預設證書,release要使用自己的證書
2.進行舉例
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
signingConfigs {
release {
storeFile file("myreleasekey.keystore") // 簽名文件
storePasswork "password" // 簽名文件的密碼
keyAlias "MyReleaseKey" // 簽名證書中秘鑰別名
keyPassword "password" // 該證書中秘鑰的密碼
// 還有一個屬性storeType簽名證書的類型
}
}
debug {
storeFile("mydebugkey.keystore")
storePasswork "passwork"
keyAlias "MyDebugKey"
keyPassword "password"
}
}
三、源碼
- gitee路徑:https://gitee.com/dongqianrui/AndroidStudioProject/tree/master/Test1
- CSDN:https://blog.csdn.net/weixin_44630050
- 博客園:https://www.cnblogs.com/ruigege0000/
- 歡迎關註微信公眾號:傅里葉變換,個人賬號,僅用於技術交流