关于 gradle:Android 风格签名无法按预期工作
Android flavors signing not working as expected
我需要使用特定的签名配置对产品风格进行签名。我在 stackoverflow 上找到了一些参考,例如 this 和 this。它适用于我的版本版本,但不适用于调试版本。我在 gradle 中有这个配置:
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
...
signingConfigs { release { storeFile file("../config/keystores/release_keystore") storePassword"mysecurepassword" keyAlias"myultrasecurealias" keyPassword"myreallysecurekeypassword" } debug { other { flavorDimensions"dim" productFlavors { other { buildTypes { debug { |
这对于风味 otherRelease 非常有效。但是当我使用构建配置 otherDebug 时,我的 APK 没有使用 other 签名配置进行签名。
release 版本已正确签名。
有谁知道为什么在调试模式下签名配置没有按照配置应用?
相关讨论
- "But it\'s not working for otherDebug" 定义"it\'s not working" 的含义。
- 对不起,我想这不是很清楚。它没有使用我在 productFlavors.other.signingConfig signingConfigs.other 中定义的 other 签名配置进行签名。我会更新我的问题。
- 它与哪个密钥库签署?还是根本没有签名?
- 有没有简单的方法来获取签名信息?我没有找到。我所做的是将我的密码更改为无效密码,因此 release 版本因密码错误而中断,而 debug 组装了一个有效的 APK。我还在设备中安装了 productionDebug,我可以用 otherDebug 替换它,这意味着它们具有相同的签名信息(我没有收到任何关于签名差异的警告)。
感谢@AllanHasegawa 在另一个问题中的评论:用 gradle 签署产品风味,我终于弄清楚了哪里出了问题。简而言之,我必须在 buildTypes 中添加 signingConfig null,因为 Android 添加了一些默认签名配置。即使我试图覆盖它。基于我的问题的完整示例:
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
...
signingConfigs { release { storeFile file("../config/keystores/release_keystore") storePassword"mysecurepassword" keyAlias"myultrasecurealias" keyPassword"myreallysecurekeypassword" } debug { other { flavorDimensions"dim" productFlavors { other { buildTypes { // this loop is a better implementation than my previous example debug { |