gpt4 book ai didi

android - 构建应用程序的调试版本时是否可以忽略 storeFile?

转载 作者:行者123 更新时间:2023-11-29 14:43:45 24 4
gpt4 key购买 nike

问题的症结在于并非所有使用此应用程序的人都可以访问存储文件,并且必须按照以下方式注释掉这些行才能进行 gradle 同步:

signingConfigs {
release {
// storeFile file('.../android_keystore.keystore')
// storePassword RELEASE_STORE_PASSWORD
// keyAlias RELEASE_KEY_ALIAS
// keyPassword RELEASE_KEY_PASSWORD
}
}

在我们的构建类型中,我们定义在调试中没有签名配置:

buildTypes{
release {
...
}
debug {
singingConfig null
...
}
}

问题是 Gradle Syncs 与构建类型无关,因此它每次都会检查签名配置(storePassword、keyAlias、keyPassword),除非我将这些行注释掉。

是否有更自动化的方法来忽略这些行?

最佳答案

你可以这样使用:

android {

signingConfigs {
release
}

buildTypes {
release {
signingConfig signingConfigs.release
}
}
}

def Properties props = new Properties()
def propFile = new File('signing.properties')
if (propFile.canRead()){
props.load(new FileInputStream(propFile))

if (props!=null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
} else {
println 'signing.properties found but some entries are missing'
android.buildTypes.release.signingConfig = null
}
}else {
println 'signing.properties not found'
android.buildTypes.release.signingConfig = null
}

signing.properties 是:

STORE_FILE=/path/to/your.keystore
STORE_PASSWORD=yourkeystorepass
KEY_ALIAS=projectkeyalias
KEY_PASSWORD=keyaliaspassword

关于android - 构建应用程序的调试版本时是否可以忽略 storeFile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49053305/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com