gpt4 book ai didi

android - 强制使用相同的证书来签署为特定 "buildTypes"配置的不同 "productFlavor"?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:04:23 33 4
gpt4 key购买 nike

背景:

我正在使用构建变体生成构建。以下是配置:

signingConfigs {
production {
storeFile file("some_path/buildsystem/keystore/some.release.keystore.jks")
storePassword "somepassword"
keyAlias "somekeyalias"
keyPassword "some"
v2SigningEnabled false
}

develop {
storeFile file(".some_path./buildsystem/keystore/someother.debug.keystore.jks")
storePassword "someother"
keyAlias "someotherkeyalias"
keyPassword "someother"
v2SigningEnabled false
}
}

productFlavors {
production {
signingConfig signingConfigs.production
}

develop {
applicationIdSuffix ".develop"
signingConfig signingConfigs.develop
}
}

buildTypes {
debug {
minifyEnabled false
}

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}

问题

例如,现在如果我谈论 flavor production 那么 productionRelease 使用 signingConfigs.production 来签署apk。但是,productionDebug 不使用 signingConfigs.production

预期输出

当我生成签名的 apk 时,我希望 gradle 为我执行以下操作:

  1. developReleasedevelopDebug 应该只用 signingConfigs.develop

  2. productionReleaseproductionDebug 应该只用 signingConfigs.production

另一个与此类似的问题导致我执行上述操作:SHA-1 different for buildTypes (debug and release) for same productFlavors Firebase?

最佳答案

删除signingConfig signingCongigs.develop 在代码块的其他地方

并在 buildTypes 中添加新属性,例如

  • 与生产
  • 与开发

现在添加signingConfig

因此,您更新后的 gradle 文件如下所示

signingConfigs {
production {
storeFile file("some_path/buildsystem/keystore/some.release.keystore.jks")
storePassword "somepassword"
keyAlias "somekeyalias"
keyPassword "some"
v2SigningEnabled false
}

develop {
storeFile file(".some_path./buildsystem/keystore/someother.debug.keystore.jks")
storePassword "someother"
keyAlias "someotherkeyalias"
keyPassword "someother"
v2SigningEnabled false
}
}
productFlavors {
production {
}

develop {
applicationIdSuffix ".develop"
}
}
buildTypes {
/* NOTE: the debug block is not required because it is a default
* buildType configuration; all of its settings are defined implicitly
* by Gradle behind the scenes.
*/
debug {
minifyEnabled false
}

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.production
}

withProduction {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.production
}

withDevelop {
minifyEnabled false
signingConfig signingConfigs.develop
debuggable true

}
}

在终端中使用下面的 gradle 命令:gradle assembleProduction 生成带有生产证书的构建类似地 gradle assembleDevelop 或者你也可以使用 gradle assemble

您不能强制 gradle 为 debug 属性选择证书,而是您可以创建自己的 buildTypes

根据 documentation

Automate signing your applications. Debug build variants are, by default, signed with a debug key for installation on development devices. Declare additional signing configurations for publication to the Google Play store.

更新:正如另一个答案指出的那样,

Add debuggable true property under custom buildTypes against which you want to debug build and see the logs.

关于android - 强制使用相同的证书来签署为特定 "buildTypes"配置的不同 "productFlavor"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45166152/

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