gradle这个assembleRelease使用错误的密钥/证书 [英] gradle assembleRelease uses wrong key/certificate

查看:1721
本文介绍了gradle这个assembleRelease使用错误的密钥/证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于gradle这个-Android项目,并试图产生一个释放的apk。然而,似乎,不知怎的被的gradle拿起错了钥匙/证书。

I have a gradle-based android project and trying to generate a release apk. However, it seems that somehow gradle is picking up the wrong key/cert.

这是我在的build.gradle:

This is what I have in build.gradle:

signingConfigs {
    release {
        storeFile file("mykey.jks")
        storePassword "mypass"
        keyAlias "mykey.key"
        keyPassword "mypass"
    }
}

buildTypes {
    release {
        debuggable false
        jniDebugBuild false
        runProguard true
        proguardFile getDefaultProguardFile('proguard-android.txt')
        signingConfig signingConfigs.release
    }
}

和运行后

gradlew assembleRelease

和采取了META-INF / CERT.RSA我运行下面的apk文件里面:

and taking out META-INF/CERT.RSA from inside the .apk I run the following:

keytool -list -keystore mykey.jks

keytool -printcert -v -file CERT.RSA

但它们产生具有不同证书的指纹输出。与使用相同的密钥签名的(但不是gradle这个)其他APK证书试图得到正确的证书指纹。

but they produce output with different certificate fingerprints. Trying with a certificate from another apk signed with the same key (but not with gradle) yields the correct certificate fingerprint.

摇篮,似乎是捡了密钥库精(更改密码或位置或别名使其停止工作)。

Gradle seems to be picking up the keystore fine (changing the password or location or alias makes it stop working).

我很困惑,因为我不希望释放一些与未知的密钥签名的存储,然后无法更新。我没有的gradle中明确定义调试键。

I'm puzzled since I don't want to release something to the store signed with an unknown key and then not be able to update it. I don't have a debug key explicitly defined in gradle.

更新:这有什么做的密钥库。尝试的gradle相同code用新鲜的密钥库和重点工作的罚款。这个问题的密钥库是从PKCS#12格式(.p12文件)导入。使用的IntelliJ或虽然的jarsigner使用该密钥库工作得很好,它只是gradle这个code具有不同的输出 - 它似乎只是从密钥生成证书是不同的。

UPDATE: This has something to do with the keystore. Trying the same gradle code with a fresh keystore and key works fine. This problematic keystore was imported from a pkcs#12 format (.p12 file). Using Intellij or jarsigner works fine with this keystore though, it's just the gradle code that has a different output - and it seems only the certificate generated from the key is different.

推荐答案

这里唯一的解决办法是打开一个新的密钥。在previous重点已经从PKCS12格式的进口,我认为这在某种程度上造成了gradle这个code生成不同的证书比的jarsigner。

The only solution here was to start with a fresh key. The previous key had been imported from a PKCS12 format and I think that somehow caused the gradle code to generate a different certificate than jarsigner.

这篇关于gradle这个assembleRelease使用错误的密钥/证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆