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
Log
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
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!
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.
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.
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.
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!