Android Gradle:signingConfig.name 不能为空
Posted
技术标签:
【中文标题】Android Gradle:signingConfig.name 不能为空【英文标题】:Android Gradle: signingConfig.name must not be null 【发布时间】:2020-06-08 22:20:31 【问题描述】:将 Gradle Wrapper 更新到 5.6.4 并将 Gradle Plugin 更新到 3.6.0 后,我收到以下错误:
Caused by: java.lang.IllegalStateException: signingConfig.name must not be null
我的配置如下:
根:
ext
Properties localProps = new Properties()
localProps.load(rootProject.file('local.properties').newDataInputStream())
mySigningConfigs = [
debug : SigningConfig.newInstance([
keyAlias : "$localProps['keyAlias']",
keyPassword : "$localProps['keyPassword']",
storeFile : file('carrierKeystore.jks'),
storePassword: "$localProps['storePassword']"
]),
release: SigningConfig.newInstance([
keyAlias : "$localProps['keyAlias']",
keyPassword : "$localProps['keyPassword']",
storeFile : file('carrierKeystore.jks'),
storePassword: "$localProps['storePassword']"
])
]
模块:
buildTypes
debug
signingConfig mySigningConfigs.debug
release
signingConfig mySigningConfigs.release
它以前很好用,但不是总是说name
为空。你有什么主意吗?谢谢。
【问题讨论】:
你有什么进展吗?我面临着完全相同的问题 【参考方案1】:我发现了问题
移动线条
buildTypes
debug
signingConfig mySigningConfigs.debug
release
signingConfig mySigningConfigs.release
到
signingConfigs
debug
mySigningConfigs.debug
release
mySigningConfigs.release
并将 signingConfigs 块放在 android 块的顶部
即
android
signingConfigs
...
defaultConfigs
...
buildTypes
...
【讨论】:
【参考方案2】:在我的情况下,other answers 没有帮助。但是将signingConfigs
从ext
部分(可能是您的根gradle 文件)直接移动到模块gradle 的android
块是有效的。所以尝试以下方法:
在android
块内添加
signingConfigs
// optional read your properties with the signingConfig data
// but keep in mind that you may have to adapt your file paths
release
keyAlias "<keyAliasValue>"
keyPassword "<keyPasswordValue>"
storeFile file('<keyStoreFileName>')
storePassword "<keyStorePasswordValue>"
.
.
.
在buildTypes
-> release
部分中,您可以保留具体的分配signingConfig
buildTypes
release
signingConfig signingConfigs.release
.
.
.
那么您可能需要从
调整您的路径(localProps 和存储文件)rootProject.file('local.properties')
storeFile file('carrierKeystore.jks')
到
// adapt to new path of the files
rootProject.file('../local.properties')
storeFile file('../carrierKeystore.jks')
【讨论】:
【参考方案3】:你的 andorid 块中必须有一个 signingConfigs 块。 像这样
signingConfigs
release
appSigningConfigs.release
defaultConfig
...
signingConfig signingConfigs.release
【讨论】:
以上是关于Android Gradle:signingConfig.name 不能为空的主要内容,如果未能解决你的问题,请参考以下文章
Android Gradle 插件Gradle 依赖管理 ① ( org.gradle.api.Project 配置 | Android Gradle 插件配置与 Gradle 配置关联 ) ★
Android Gradle 插件Android Gradle 工程结构简介 ( Gradle 默认输出目录 | Gradle 配置目录 | gradlew 可执行文件 )