# No such file or directory - zipalign

**URL:** <https://discuss.bitrise.io/t/no-such-file-or-directory-zipalign/3091>\
**Category:** Issues\
**Created:** [October 23, 2017, 11:05am UTC](https://discuss.bitrise.io/t/no-such-file-or-directory-zipalign/3091 "2017-10-23T11:05:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![annada](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@annada](https://discuss.bitrise.io/u/annada)\
**Post date:** [October 23, 2017, 11:05am UTC](https://discuss.bitrise.io/t/no-such-file-or-directory-zipalign/3091/1 "2017-10-23T11:05:03Z")

</div>

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.

```auto
#!/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

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [October 23, 2017, 1:17pm UTC](https://discuss.bitrise.io/t/no-such-file-or-directory-zipalign/3091/2 "2017-10-23T13:17:50Z")

</div>

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):

```auto
$ 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! 🙂

---

<div class="post-metadata">

**Author:** ![annada](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@annada](https://discuss.bitrise.io/u/annada)\
**Post date:** [October 23, 2017, 1:33pm UTC](https://discuss.bitrise.io/t/no-such-file-or-directory-zipalign/3091/3 "2017-10-23T13:33:05Z")

</div>

> [@viktorbenei](#):
>
> ANDROID\_HOME

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

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [October 23, 2017, 1:36pm UTC](https://discuss.bitrise.io/t/no-such-file-or-directory-zipalign/3091/4 "2017-10-23T13:36:32Z")

</div>

Hi,

> [@annada](#):
>
> In fastlane Fastfile.rb script, where I am calling zipalign?

You should ask this from the `fastlane` guys / on the fastlane support 🙂

> [@annada](#):
>
> Where is config file?Are you referring bitrise.yml? Please suggest the steps to do this step.

1. Open your app on [bitrise.io](http://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

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [October 23, 2017, 1:37pm UTC](https://discuss.bitrise.io/t/no-such-file-or-directory-zipalign/3091/5 "2017-10-23T13:37:29Z")

</div>

> [@annada](#):
>
> I guessed sdkmanager “build-tools;26.0.2” line in script, should add all corresponding build tools to env.

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

---

<div class="post-metadata">

**Author:** ![annada](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@annada](https://discuss.bitrise.io/u/annada)\
**Post date:** [October 23, 2017, 2:22pm UTC](https://discuss.bitrise.io/t/no-such-file-or-directory-zipalign/3091/6 "2017-10-23T14:22:24Z")

</div>

> [@annada](#):
>
> Viktorbenei

Hi Viktorbenei,

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

Regards  
Annada

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [October 23, 2017, 2:37pm UTC](https://discuss.bitrise.io/t/no-such-file-or-directory-zipalign/3091/7 "2017-10-23T14:37:29Z")

</div>

Any time 😉

Happy Building!
