Zipalign - 未找到命令 - MAC 终端
当我尝试在 apk 上运行 Zipalign 时,出现错误“找不到命令”
我不太熟悉在 MAC 上使用终端命令,但我已导航到 SDK/Tools 文件夹并运行以下命令:
zipalign -v 4 Project1.apk Project1-aligned.apk
我得到 Command not found
我尝试将 APK 放在 Tools 文件夹中,结果相同。
有人可以帮助我了解 apk 应该位于哪里以及我应该从哪里运行 zipalign 吗?
谢谢,我对此感到非常沮丧,因为它看起来很简单。
When I try to run Zipalign on an apk I get the error "Command not found"
I am not that familiar with using terminal commands on the MAC but I have navigated to the SDK/Tools folder and run the following command:
zipalign -v 4 Project1.apk Project1-aligned.apk
I get Command not found
I have tried placing the apks in the Tools folder and same result.
Can someone help me to understand where the apks should be located and where I should run zipalign from?
Thanks, I am very frustrated about this as it seems so simple.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(23)
您可以使用此命令找到正确的路径:
You can find correct path with this command:
也许当前目录不在您的路径中?
尝试在命令前添加“./”
Perhaps the current directory is not in your path?
Try adding "./" before your command so
您将在工具文件夹中的
/path/to/sdk/build-tools//zipalign
中找到 zipalign 工具不再。You will find the zipalign tool at
/path/to/sdk/build-tools/<build-tools-version>/zipalign
NOT in the tools folder anymore.将其拖到终端或将其保存在您的路径中。
xxxx->版本
Drag this to terminal or save this in your path.
xxxx -> Version
Zipalign 是一个位于
$ANDROID_HOME/build-tools/{android-version}/
的命令。希望有帮助。
Zipalign is a command that located at
$ANDROID_HOME/build-tools/{android-version}/
.Hope it helped.
一个简单的一行:
echo "export PATH=\$PATH:~/Library/Android/sdk/构建工具/23.0.1/">> 〜/.bash_profile && 。 ~/.bash_profile
确保将 23.0.1 替换为您安装的版本
现在,无论您当前的工作目录如何,您都应该能够使用 zipalign
$ zipalign
A simple one-liner:
echo "export PATH=\$PATH:~/Library/Android/sdk/build-tools/23.0.1/" >> ~/.bash_profile && . ~/.bash_profile
Make sure to replace 23.0.1 with your installed version
Now you should be able to use zipalign regardless of your current working dir
$ zipalign
在带有 zsh 控制台的 Mac 上,我的解决方案是
命令 1)
命令 2)
命令 3)
命令 4)
on the mac with the zsh console, my solution was
command 1)
command 2)
command 3)
command 4)
新手(像我一样)的 2 小时恢复:
如果你输入这个命令:
女巫给你:
可能路径有问题。
如果你有这样的情况:
它证实它并不真正应该是这样的。因此,要执行 zipalign 并最终发布您的应用程序,您必须进入正确的存储库并执行 commande。
1.转到正确的存储库执行命令:
路径为 cd /Users/xxxyour_user_namexxx/Library/Android/sdk/build-tools/xxxxx/
2.执行你的zipalign命令,不要忘记精确的apk文件的路径:
显然,“greg”和“myapp”可能是你的用户名&应用程序名称。
希望有帮助。
2hours resume for newbies (like me) :
If you type this command :
Witch gives you :
It's maybe that the path is somewhere wrong.
If you have this :
It confirms that its not really as it should be. So, to execute zipalign and finally publish your app, you have to go in the correct repository and execute commande.
1. Go to the correct repo to execute command :
The path is cd /Users/xxxyour_user_namexxx/Library/Android/sdk/build-tools/xxxxx/
2. Execute your zipalign command, don't forget to precise the path of apk file :
Obviously, chance "greg" and "myapp" with your user name & app name.
Hope it helps.
搜索它并引用它...我在这里有它并像这样引用它:
/Users/lioncio/Desktop/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/zipalign bla bla bla (命令的所有选项!)
并且有效
Search it and reference it... I have it here and reference it like this:
/Users/lioncio/Desktop/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/zipalign bla bla bla (all the options of the command!)
And worked
放松! ,只要在终端中使用
Locate
命令无论它在哪里,它就会出来在我的例子中它被埋在这里
Relax! , Just Use
Locate
Command in Terminal WHEREVER it is , it will come outIn my case it was burried over here
路径
将其添加到终端上的
查找 zip 对齐路径的
路径: /Users/username/Library/Android/sdk/build-tools/26.0.1/zipalign
输入在那里找到的路径
add it to the path
on terminal
find path for zip align
path: /Users/username/Library/Android/sdk/build-tools/26.0.1/zipalign
enter the path found in there
Mac 的解决方案
此错误基本上意味着终端无法找到 zipalign 文件。
因此,您可以使用命令(位于 Android build-tools 文件夹中)输入 zipalign 文件的完整路径。
如果您不知道 zipalign 文件的位置,则只需使用此命令
Solution for Mac
This error basically means that the terminal wasn't able to find the zipalign file.
So you can either type in the full path for your zipalign file with the command (located in your Android build-tools folder)
If you do not know the location of the zipalign file, then just use this command
如果您使用的是 Windows,请将命令提示符更改为指向包含 zipalign.exe 的文件夹,然后运行该命令。另外,我发现您没有使用完整的命令:
If you are working on Windows, change the command prompt to point to the folder containing the zipalign.exe and then run the command. Also, I have found that you are not using the complete command:
cd android-sdk/build-tools/22.0.0/
- 将目录更改为 android sdk 文件夹,构建工具并选择版本(我使用的是 22.0.0)。然后在提示符处输入:
这对我有用。我尝试了上面的其他解决方案,但没有成功。我只需在正确的文件夹中运行命令,但在我检查的其他资源中没有清楚地解释这一点。
cd android-sdk/build-tools/22.0.0/
- change directory to android sdk folder, build tools and choose version (I used 22.0.0).Then at the prompt type:
That worked for me. I tried the other solutions above with no success. I just had to run the command withn the proper folder, but that wasn't explained clearly in other resources I checked.
导航到 zipalign 的路径并使用命令
/Users/ignatiusandrew/Library/Android/sdk/build-tools/25.0.2/zipalign 4 android-release-unsigned.apk igi 包含该路径。 apk
Navigate to the path of the zip align and include that with the command
/Users/ignatiusandrew/Library/Android/sdk/build-tools/25.0.2/zipalign 4 android-release-unsigned.apk igi.apk
或者,如果您不想将特定的构建工具文件夹添加到路径中,以防将来它发生变化,您可以使用
find
命令的第一个结果:$(find ~ /Library/Android/sdk/build-tools -name "zipalign" | head -n 1)
它在 CI 管道中可能特别有用。
Alternatively, if you do not want to add a specific build tools folder to the path, in case it changes in the future, you can use the first result of
find
command:$(find ~/Library/Android/sdk/build-tools -name "zipalign" | head -n 1) <your-zipalign-parameters>
It might be especially useful in a CI pipeline.
对我来说,这工作得很好,我将 zipalign 文件从 android 路径复制到我想要运行命令的文件夹,然后输入 ./zipalign -v 4 android-release-unsigned.sdk nameofapp.apk
注意:它是在 Mac 上
for me this worked perfectly, I copied the zipalign file from the android path to the folder where I wanted to run command and then typed ./zipalign -v 4 android-release-unsigned.sdk nameofapp.apk
Note: It was on Mac
第一的,
如果你的android home已经设置好了,那么你就可以
cd $ANDROID_HOME
和
open .
(这应该是 - /Users/username/Library/Android/,您也可以直接 cd 到该路径)接下来,导航到“sdk/build-tools/25.0.3/” (本例中为版本 25.0.3,您的版本可能不同)。
在您的终端(apk 提示符)中,将 zipalign 拖到终端并
...../zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
。应该可以正常工作。
希望有帮助。
First,
if your android home is set, then you can just
cd $ANDROID_HOME
and
open .
(This should be - /Users/username/Library/Android/, you can just cd to that path as well)Next, navigate to "sdk/build-tools/25.0.3/" (version 25.0.3 in this case, yours may be a different version).
At your terminal (apk prompt), drag zipalign to the terminal and
...../zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
.Should work fine.
Hope it helps.
从 github 下载 zipalign 文件
Downloaded zipalign-file from github
就我而言
我遵循以下答案
更改目录
/path/to/sdk/build-tools//zipalign
类型
./zipalign 而不是 zipalign
简而言之 ./zipalign 是我的解决方案。
In my case
I follow below answer
Change directory
/path/to/sdk/build-tools//zipalign
Type
./zipalign instead zipalign
In short ./zipalign is solution for me.
Jenkins 解决方案
对于使用 MacOS 构建和签名移动应用程序的 Jenkins 用户遇到此错误,解决方案可能是这样的:
在进行签名的阶段:
Solution for Jenkins
For Jenkins users using MacOS to build and sign mobile apps who are experiencing this error, the solution could be this:
At the stage where the signature is made:
我使用的是 Windows,
需要在环境变量中配置 git bash/command promt zipalign.exe。
因此,请包含 sdk 文件夹“build-tool”以及您用于构建的 Android 版本文件夹。
它应该包含“zipalign.exe”。现在您可以
使用命令行工具从任何位置进行用户操作。
为我点赞,这样我就可以帮助更多的开发者。
I am using Windows with git bash/command promt
zipalign.exe needed to be configured in environment variables.
so include sdk folder 'build-tool' with android version folder you are using to build.
it should contain 'zipalign.exe'. now you can user
from any location using command line tools.
thumb up for me so i can help more developers.