Can't create a release apk with keystore file

android

#1

Hi guys, I cannot for the life of me figure out how to do a release build because I’m useless at this CI stuff. I’ve read your doc on code signing at least 5 times now :smiley: .

I wanted to go for option 2 because I’d rather not have to touch my gradle file. So I uploaded the keystore to BitRise, set the password etc, changed the default Gradle Runner to assembleRelease, and added a sign-apk workflow step after the gradle runner.
I get an error telling me it can’t find a keystore so the build fails. What do you think I’m doing wrong here?


I then tried option 1 and modified my build.gradle with a new signing config:

release{
        v2SigningEnabled false
        keyAlias System.getenv("BITRISEIO_ANDROID_KEYSTORE_ALIAS")
        keyPassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD")
        storeFile file(System.getenv("BITRISEIO_ANDROID_KEYSTORE_URL"))
        storePassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PASSWORD")
    }

That didn’t work either, it can’t find the keystore:
annot convert URL '<‘https://concrete-userfiles-production.s3-us-west-2.amazonaws.com/project_file_storage_documents/uploads/ - <snip>’ to a file.


Cannot sign the apk
#2

Na’, first steps are always hard but you’ll get into it in no time, don’t worry! :wink:

I’d suggest as well if you’re getting started.

Sounds good :slight_smile:

I’d suggest you to revert that change, it’s not required if you go with option 2. Let’s stick with Option 2, using the Sign APK step :wink:

Could you please copy paste the related build’s bitrise.io URL? Sounds like a minor misconfiguration - with the URL I can check the logs & the config the build ran with :wink:


#3

Thanks Viktor! Here is the most recent build. Correct me if I’m wrong but does the gradle task assembleRelease not just attempt to create a signed apk in one step (using whatever environment variables are in the gradle)? In which case I need to create an unsigned apk first I guess and somehow pass it to the sign-apk task.

If it makes any difference my assemble task is actually a build variant: assembleRelease_slim, but I don’t think that matters.


#4

From the log of the build:

Caused by: java.lang.IllegalArgumentException: Keystore file not set for signing config release

Are you sure that you reverted the build.gradle changes (the ones mentioned here http://devcenter.bitrise.io/android/code-signing/#1-specify-code-sign-configuration-in-your-project )? It seems your build.gradle is still configured to use a keystore file.

I’d suggest you to remove the signingConfigs section from there (e.g. https://github.com/bitrise-samples/sample-apps-android-sdk22/blob/master/app/build.gradle); that should allow gradle to generate an unsigned release APK, which then can be signed by the Sign APK step.

Let me know how it goes or if you’d have any questions! :wink:


[Android] Sign APK Step Error: unsupported protocol scheme "". Fail using existing release .keystore file
#5

Hey there, I struggled with this for a while and realized that it was due to a missing build.gradle configuration:

// make sure you include signingConfigs above the buildTypes block
signingConfigs {
    release {
        keyAlias System.getenv("BITRISEIO_ANDROID_KEYSTORE_ALIAS")
        keyPassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD")
        storeFile file(System.getenv("HOME") + "/keystores/bcs.jks")
        storePassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PASSWORD")
    }
}

//include signingConfig.release in your release buildType configuration. 
buildTypes {
    debug {
     ...
    }
    release {
    ...
        signingConfig signingConfigs.release
    }
}

Perhaps a rookie mistake, but could be a good idea to cover this in the documentation.