No such file or directory - zipalign

Hi,
I am trying to build android project, with fastlane script. But build failed, with “No such file or directory - zipalign”.
Zipalign is present in android platform build-tools, so I have added script to add build-tools with script step, like below.

#!/bin/bash
# fail if any commands fails
set -e
# debug log
set -x

# write your script here
sdkmanager "platforms;android-26"
sdkmanager "build-tools;26.0.2"

But still, it is not able to find zipalign, please help, what may be the issue?

Regards
Annada

Hi,

zipalign is part of the build-tools android package, but that package does not add the related directory to the PATH by default.

In fact, if you search for the zipalign binary you’ll see that there’s one for every build tools version (I ran this on the current Linux/Android stack):

$ find "$ANDROID_HOME" -iname '*zipalign*'

/opt/android-sdk-linux/build-tools/19.1.0/zipalign
/opt/android-sdk-linux/build-tools/21.1.2/zipalign
/opt/android-sdk-linux/build-tools/22.0.1/zipalign
/opt/android-sdk-linux/build-tools/23.0.3/zipalign
/opt/android-sdk-linux/build-tools/24.0.3/zipalign
/opt/android-sdk-linux/build-tools/25.0.3/zipalign
/opt/android-sdk-linux/build-tools/26.0.1/zipalign
/opt/android-sdk-linux/build-tools/26.0.2/zipalign

So, if you want to run zipalign you should either reference it with a full path (e.g. "$ANDROID_HOME/build-tools/25.0.3/zipalign") or add the related build-tools dir to your path (e.g. with an Env Var in your config, where the key is PATH and the value is $PATH:$ANDROID_HOME/build-tools/25.0.3).

I hope this helps, if you have any questions just let us know! :slight_smile:

Thanks Viktorbenei for your help regarding this issue.

I guessed sdkmanager “build-tools;26.0.2” line in script, should add all corresponding build tools to env. If this is not true, I am fine to proceed with your suggestion.

Two doubts I have here, from your two suggestions.

  1. Reference it with a full path (e.g. “$ANDROID_HOME/build-tools/25.0.3/zipalign”) , where to add this?
    In fastlane Fastfile.rb script, where I am calling zipalign?
    The line I am calling zipalign is,
    zipalign(apk_path: “#{lane_context[SharedValues::SIGNED_APK_PATH]}”)

It should be :-
$ANDROID_HOME/build-tools/25.0.3/zipalign(apk_path: “#{lane_context[SharedValues::SIGNED_APK_PATH]}”)

  1. add the related build-tools dir to your path (e.g. with an Env Var in your config, where the key is PATH and the value is $PATH:$ANDROID_HOME/build-tools/25.0.3).
    Where is config file?Are you referring bitrise.yml? Please suggest the steps to do this step.

Regards
Annada

Hi,

You should ask this from the fastlane guys / on the fastlane support :slight_smile:

  1. Open your app on bitrise.io
  2. Select the Workflow tab
  3. In the workflow editor select Env Vars tab
  4. There you can specify the PATH = $PATH:$ANDROID_HOME/... variable

No it does not add that directory to the PATH. In fact no package install (sdkmanager ...) does.

Hi Viktorbenei,

After setting the PATH env, it passed the zipalign step.
Thanks for your help.

Regards
Annada

1 Like

Any time :wink:

Happy Building!