简体   繁体   中英

Android gradle build release not finding alias in keystore

I am attempting to use Cordova to build in release. I have release-signing.properties declared in platforms/android with the following content:

storeFile=../../release-key.jks
storePassword=<password>
storeType=pkcs12
keyAlias=<alias>
keyPassword=<password>

Using either:

cordova build android --release

or just using gradle:

./gradlew.bat signingReport

Both report an issue building for release:

Failed to read key mmrevision from store "<full_path>\platforms\android\..\..\release-key.keystore": DerInputStream.getLength(): lengthTag=109, too big.

I generated the key with:

/C/Program\ Files\ \(x86\)/Java/jre1.8.0_65/bin/keytool.exe -genkey -v -keystore release-key.jks -alias mmrevision -keyalg RSA -keysize 2048 -validity 36500

My issue was that, I generated the key as androids documentation suggests, but I copied the config for release-signing from cordova's documentation.

The flaw in this is that cordova listed the storeType as "pkcs12" while the keytool command I used generates a jks keystore!

Change:

storeType=pkcs12

To:

storeType=jks

Also note:

In cordova it is now better to use build.json. In the root of your cordova project add a file called "build.json" with content like:

{
    "android": {
        "debug": {
            ... (if not specified, the apk cannot be signed in debug, but cordova run android should still work)
        },
        "release": {
            "keystore": "release-key.jks",
            "storePassword": "<password>",
            "alias": "<alias>",
            "password" : "<password>",
            "keystoreType": "jks"
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM