Cannot sign the apk

Bitrise Build Issue Report template

Description of the issue

I have uploaded a key from the code signing menu of the website together with the respective environment variables for keystore and password. I have used them in the following way in my app gradle:

        def keystorePath = System.getenv("BITRISEIO_ANDROID_KEYSTORE_URL")
        def keystorePass = System.getenv("BITRISEIO_ANDROID_KEYSTORE_PASSWORD")
        def alias = System.getenv("BITRISEIO_ANDROID_KEYSTORE_ALIAS")
        def password = System.getenv("BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD")

        storeFile file(keystorePath != null ? keystorePath : signingProps["KEY_STORE_FILE_PATH"])
        storePassword (keystorePass != null ? keystorePass : signingProps["KEY_STORE_PASSWORD"])
        keyAlias (alias != null ? alias : signingProps["KEY_ALIAS"])
        keyPassword (password != null ? password : signingProps["KEY_PASSWORD"])

The build fails with the following log:
±-----------------------------------------------------------------------------+

| (4) install-missing-android-tools@2.1.1 |
±-----------------------------------------------------------------------------+
| id: install-missing-android-tools |
| version: 2.1.1 |
| collection: https://github.com/bitrise-io/bitrise-steplib.git |
| toolkit: go |
| time: 2018-07-30T02:29:49Z |
±-----------------------------------------------------------------------------+
| |
INFO[02:29:49] Start installing (golang) with apt-get
INFO[02:29:49] * [OK] Step dependency (go) installed, available.
Configs:

  • GradlewPath: gradlew
  • AndroidHome: /opt/android-sdk-linux
    Preparation
    Set executable permission for gradlew
    Initialize Android SDK
    Ensure android licences
    Ensure required Android SDK components
    Searching for missing SDK components using:
    $ ./gradlew “dependencies”
    Failed to find missing components, retrying…
    Searching for missing SDK components using:
    $ ./gradlew “dependencies”
    Failed to find missing components, retrying…
    Searching for missing SDK components using:
    $ ./gradlew “dependencies”
    Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
    FAILURE: Build failed with an exception.
  • Where:
    Build file ‘/bitrise/src/app/build.gradle’ line: 55
  • What went wrong:
    A problem occurred evaluating project ‘:app’.

Cannot convert URL ‘https://concrete-userfiles-production.s3.us-west-2.amazonaws.com/project_file_storage_documents/uploads/14170/original/…’ to a file.

I have read the following Can't create a release apk with keystore file but does not solve my issue because I do want to use environment variables to get the signing config from rather than removing them from gradle as suggested in the answer to that question.

The issue is not also related to missing android tools because when I replace the environment variables signing config with the ones bundled with the app in the repository I don’t get this issue. However, I don’t want to expose my signing config inside the repository and this is why I do want to use the environment variables for the signing config.

Environment:

Where did the issue happen?

(4) install-missing-android-tools@2.1.1

(4) install-missing-android-tools@2.1.1

E.g.: Git Clone v3.6.0

Reproducibility

  • Does a “Rebuild” help? (You can trigger a rebuild from the Build’s page, by clicking the “Rebuild” button in the top right corner of a finished build) : NO
  • Does a rebuild without caches help? (You can remove the Cache:Pull and Cache:Push steps temporarily to not to use the cache, or you can delete all the caches on the Settings tab of the app. : NO
  • Does the issue happen sporadically, or every time? :
  • Does upgrading the build Step to the latest version help? : YES/NO
  • When did the issue start? :

Local reproduction

Can it be reproduced on your own Mac/PC by following our local debug guide? Please follow at least the first section (“Testing with a full clean git clone”) to make sure to test the state of the code what bitrise.io will get when it does a git clone in the clean environment! If possible please note which sections you tried.

Local reproduction: Linux / Android (docker based) stack builds

Can it be reproduced by running the build locally, after doing a new git clone of the repository into the /tmp directory and running the build from there with the Bitrise CLI ( https://www.bitrise.io/cli )? If no, can it be reproduced with Docker (using the same docker images / environment we use on bitrise.io)? Related guide: http://devcenter.bitrise.io/docker/run-your-build-locally-in-docker/ .

Build log

Please copy paste the build’s bitrise.io URL here (or if the issue happens somewhere else then the full logs), or if you can’t share the url / log here then send the url or full log through a private channel (e.g. email - https://www.bitrise.io/contact ), with a link to the related Discuss issue.
https://app.bitrise.io/build/a6301941615a644e

Hi there,

Sorry for the long delay! So basically the issue is that the BITRISEIO_ANDROID_KEYSTORE_URL environment variable isn’t a path to the keystore file on the build machine, but a URL. I would suggest to remove the apk signing from the gradle file and use the sign-apk step instead, but as this wouldn’t be an option for you a solution that comes to my mind would be to have either a Script step or our File Downloader step to download the keystore file. You can set an environment variable as the target path for both cases and use this variable in your build.gradle file.

eg.: have a DOWNLOADED_KEYSTORE_PATH variable with the desired download location and use
curl -o $DOWNLOADED_KEYSTORE_PATH $BITRISEIO_ANDROID_KEYSTORE_URL
Or
Set the Download source url input of the File Downloader step to $BITRISEIO_ANDROID_KEYSTORE_URL and the Download destination path to $DOWNLOADED_KEYSTORE_PATH

After that you can update the gradle file to have
def keystorePath = System.getenv("DOWNLOADED_KEYSTORE_PATH")

Let me know if you’d have any issues or questions about these!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.