目录结构如下:

e6bda401bf3d366df2ef2e81d8a90906.png

有2种方式:

第一种,直接配置:

signingConfigs {

debug {

storeFile file("app/keystore.properties")

storePassword "111111"

keyAlias "key"

keyPassword "111111"

}

release {

storeFile file("app/keystore.properties")

storePassword "111111"

keyAlias "key"

keyPassword "111111"

}

}

buildTypes {

debug {

signingConfig signingConfigs.debug

}

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

signingConfig signingConfigs.release

}

}

第二种,通过读取文件

新建keystore.properties文件

storeFile=keyStore.jks

storePassword=123456

keyAlias=encrypt

keyPassword=123456

build.gradle配置

signingConfigs {

// 从keystore.properties文件中读取信息

def keystorePropertiesFile = rootProject.file("app/keystore.properties")

def keystoreProperties = new Properties()

keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

debug {

println("======== debug mode: set key ========")

storeFile file(keystoreProperties['storeFile'])

storePassword keystoreProperties['storePassword']

keyAlias keystoreProperties['keyAlias']

keyPassword keystoreProperties['keyPassword']

}

release {

println("======== release mode: set key ========")

storeFile file(keystoreProperties['storeFile'])

storePassword keystoreProperties['storePassword']

keyAlias keystoreProperties['keyAlias']

keyPassword keystoreProperties['keyPassword']

}

}

buildTypes {

debug {

signingConfig signingConfigs.debug

}

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

signingConfig signingConfigs.release

}

}

总结

以上所述是小编给大家介绍的Android 配置打包签名信息的两种方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐