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?
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):
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!
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.
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]}”)
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.