Input the signed apk path to gradle task


I am automating beta distribution (crashlytics). But for crashlyticsUploadDistributionRelease gradle task not able to set apk file path as $BITRISE_SIGNED_APK_PATH.

Step1:- Gradle Runner step:- which does gradlew assembleRelease.
(And copy ./app/build/outputs/apk/release/app-release-unsigned.apk to /bitrise/deploy/app-release-unsigned.apk)

Step2:- Sign APK Step:- Log says “The Signed APK path is now available in the Environment Variable: BITRISE_SIGNED_APK_PATH (value: /bitrise/deploy/app-release-bitrise-signed.apk)”

Step 3:- Gradle Runner step:- crashlyticsUploadDistributionRelease
Uploading /bitrise/src/app/build/outputs/apk/release/app-release-unsigned.apk to Crashlytics…
WARN - Crashlytics halted compilation because it can’t distribute the unsigned APK: /bitrise/src/app/build/outputs/apk/release/app-release-unsigned.apk

Please help to input the BITRISE_SIGNED_APK_PATH to Step 3:- Gradle Runner step:- crashlyticsUploadDistributionRelease


There are lot of things I’ve tried with no success. As always crashlyticsUploadDistributionRelease task looking apk from /release/apk/ directory.

Those are:-

  1. Added file download step to copy signed apk from deploy directory to /release/apk/ directory.
  2. Added script step to copy signed apk from deploy directory to /release/apk/ directory.

But nothing is working, please help me.

Hi @adiget,

Can you please open the related build and copy paste its URL here, so that we can look into it?

1 Like

Hi Viktorbenei,
Thanks for your reply.




Kindly look into the build, link shared.

I am trying to give input the signed-apk-path to the gradle task crashlyticsUploadDistributionRelease, but not able to find the way. Please help.


1 Like

Hi @adiget,

Checked your log & config, it seems that in your Script step you try to move a file which does not exist.

I’d suggest you to change the Script step’s content to this one:

#!/usr/bin/env bash
set -ex

mkdir -p "$BITRISE_SOURCE_DIR/app/build/outputs/apk/release"
cp "$BITRISE_SIGNED_APK_PATH" "$BITRISE_SOURCE_DIR/app/build/outputs/apk/release/app-release-unsigned.apk"

It seems your gradle project includes a crahlytics config which is hardcoded to upload the file from the path: app/build/outputs/apk/release/app-release-unsigned.apk

The above script will copy the previously generated signed apk there (the one you generate with the Sign APK step before the script step).

Please let me know if that’s not what you want (to upload the signed APK, even though your gradle crashlytics crashlyticsUploadDistributionRelease task is configured for an app-release-unsigned.apk APK file) or if I missed something!

1 Like

Thanks for your suggestion regarding script to copy signed apk. First time I could able to build and uploaded signed apk successfully.

What I feel, this does not looks right way to deploy signed apk. What I want given below.

  1. Is there any way “gradle task crashlyticsUploadDistributionRelease” picks apk from path as $BITRISE_SIGNED_APK_PATH, as sign-apk step produces signed apk in that path($BITRISE_SIGNED_APK_PATH)?

You mentioned,
“It seems your gradle project includes a crashlytics config which is hardcoded to upload the file from the path: app/build/outputs/apk/release/app-release-unsigned.apk”.

I am not sure, where it is that in my gradle project, I just followed steps mentioned here . No where I can’t find the apk path configuration for crashlytics.

on bitrise, also I have tried with crashlyticsUploadDistributionRelease -PuploadDist=$BITRISE_SIGNED_APK_PATH as gradle-task step(7). Please look into the bitrise build. No success as it is still looking apk from path(/bitrise/src/app/build/outputs/apk/release/app-release-unsigned.apk), NOT from $BITRISE_SIGNED_APK_PATH.

  1. In previous gradle-runner step(6), it is generating apk. And copying to deploy path.
    copy ./app/build/outputs/apk/release/app-release-unsigned.apk to /bitrise/deploy/app-release-unsigned.apk

Can we skip this, and eventually sign-apk step(7) should generate signed apk to ./app/build/outputs/apk/release/ rather than /bitrise/deploy/ path?

If this is possible, then crashlyticsUploadDistributionRelease will get the signed apk at path ./app/build/outputs/apk/release/ , by default where it is looking for signed apk always.


Hi @viktorbenei,

As I am looking for solution, in any way crashlyticsUploadDistributionRelease tasks takes signed apk path as an parameter,

I also posted an question on stackoverflow here. This is related to crashlytics specific configuration if any.


Is there any reason why the current solution, or the one mentioned at (to specify the path in your crashlytics related gradle configs) is not optimal for you?

Does the current solution cause any issues?

Hi @viktorbenei,

Solution-1:- Script step to copy signed apk from $BITRISE_SIGNED_APK_PATH to $BITRISE_SOURCE_DIR/app/build/outputs/apk/release/app-release-unsigned.apk.

Yes this will work, but I was thinking this is not a standard way to deploy signed apk to beta on bitrise, as bitrise deploy step also takes apk from $BITRISE_SIGNED_APK_PATH. If you suggest, I am happy to go with this approach.

Solution-2. The solution suggested on Stackoverflow is configure through gradle file.
ext.betaDistributionApkFilePath = "path to the universal split APK"

The signed apk is generated at $BITRISE_SIGNED_APK_PATH on bitrise, I can set that path on gradle file, but it seems a mismatch.

If some developer builds locally(there is no $BITRISE_SIGNED_APK_PATH locally) . And there is no need to upload into crashlytics with local build. The crashlytics upload task is needed only when build on bitrise.


Sure, makes sense. In your case I’d go with Solution 1, as if I understand it correctly does work properly and fulfils all your requirements, right? If I missed something just let me know! :wink: