Zipalign - 未找到命令 - MAC 终端

发布于 2024-10-22 03:50:00 字数 323 浏览 1 评论 0原文

当我尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(23

薄荷梦 2024-10-29 03:50:00

您可以使用此命令找到正确的路径:

find ~/Library/Android/sdk/build-tools -name "zipalign"

You can find correct path with this command:

find ~/Library/Android/sdk/build-tools -name "zipalign"
远山浅 2024-10-29 03:50:00

也许当前目录不在您的路径中?

尝试在命令前添加“./”

./zipalign -v 4 Project1.apk Project1-aligned.apk

Perhaps the current directory is not in your path?

Try adding "./" before your command so

./zipalign -v 4 Project1.apk Project1-aligned.apk
暮光沉寂 2024-10-29 03:50:00

您将在工具文件夹中的 /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.

她比我温柔 2024-10-29 03:50:00
~/Library/Android/sdk/build-tools/xxxx/zipalign

将其拖到终端或将其保存在您的路径中。
xxxx->版本

~/Library/Android/sdk/build-tools/xxxx/zipalign

Drag this to terminal or save this in your path.
xxxx -> Version

时间海 2024-10-29 03:50:00

Zipalign 是一个位于 $ANDROID_HOME/build-tools/{android-version}/ 的命令。

希望有帮助。

Zipalign is a command that located at $ANDROID_HOME/build-tools/{android-version}/.

Hope it helped.

感情洁癖 2024-10-29 03:50:00

一个简单的一行:

  • 这会在您的配置文件中添加一行,将包含 zipalign 可执行文件的目录添加到您的路径
  • 然后重新加载配置文件

echo "export PATH=\$PATH:~/Library/Android/sdk/构建工具/23.0.1/">> 〜/.bash_profile && 。 ~/.bash_profile

确保将 23.0.1 替换为您安装的版本

$ ls -l ~/Library/Android/sdk/build-tools/
total 0
drwxr-xr-x  23.0.1 <---

现在,无论您当前的工作目录如何,您都应该能够使用 zipalign

$ zipalign

A simple one-liner:

  • This adds a line in your profile, to add the directory which contains the zipalign executable to your path
  • Then reloads the profile

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

$ ls -l ~/Library/Android/sdk/build-tools/
total 0
drwxr-xr-x  23.0.1 <---

Now you should be able to use zipalign regardless of your current working dir

$ zipalign

深白境迁sunset 2024-10-29 03:50:00

在带有 zsh 控制台的 Mac 上,我的解决方案是

命令 1)

find ~/Library/Android/sdk/build-tools -name "zipalign"
----------------------------------------------------------
/Users/macOs/Library/Android/sdk/build-tools/28.0.3/zipalign
/Users/macOs/Library/Android/sdk/build-tools/26.0.2/zipalign
/Users/macOs/Library/Android/sdk/build-tools/25.0.2/zipalign
/Users/macOs/Library/Android/sdk/build-tools/27.0.3/zipalign

命令 2)

echo "export PATH=\$PATH:~/Library/Android/sdk/build-tools/28.0.3/" >> ~/.bash_profile && . ~/.bash_profile

命令 3)

ls -l ~/Library/Android/sdk/build-tools/

命令 4)

zipalign -v 4 app-release-unsigned.apk nameApp.apk

on the mac with the zsh console, my solution was

command 1)

find ~/Library/Android/sdk/build-tools -name "zipalign"
----------------------------------------------------------
/Users/macOs/Library/Android/sdk/build-tools/28.0.3/zipalign
/Users/macOs/Library/Android/sdk/build-tools/26.0.2/zipalign
/Users/macOs/Library/Android/sdk/build-tools/25.0.2/zipalign
/Users/macOs/Library/Android/sdk/build-tools/27.0.3/zipalign

command 2)

echo "export PATH=\$PATH:~/Library/Android/sdk/build-tools/28.0.3/" >> ~/.bash_profile && . ~/.bash_profile

command 3)

ls -l ~/Library/Android/sdk/build-tools/

command 4)

zipalign -v 4 app-release-unsigned.apk nameApp.apk
2024-10-29 03:50:00

新手(像我一样)的 2 小时恢复:

如果你输入这个命令:

zipalign -v 4 platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk app-release.apk  

女巫给你:

command not found: zipalign

可能路径有问题。
如果你有这样的情况:

Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/apt" (-1)

它证实它并不真正应该是这样的。因此,要执行 zipalign 并最终发布您的应用程序,您必须进入正确的存储库并执行 commande。

1.转到正确的存储库执行命令:

路径为 cd /Users/xxxyour_user_namexxx/Library/Android/sdk/build-tools/xxxxx/

cd /Users/greg/Library/Android/sdk/build-tools/28.0.3

2.执行你的zipalign命令,不要忘记精确的apk文件的路径:

显然,“greg”和“myapp”可能是你的用户名&应用程序名称。

./zipalign -v 4 /Users/greg/Desktop/AppLocal/myapp/platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk /Users/greg/Desktop/AppLocal/myapp/platforms/android/app/build/outputs/apk/release/app-release.apk

希望有帮助。

2hours resume for newbies (like me) :

If you type this command :

zipalign -v 4 platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk app-release.apk  

Witch gives you :

command not found: zipalign

It's maybe that the path is somewhere wrong.
If you have this :

Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/apt" (-1)

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/

cd /Users/greg/Library/Android/sdk/build-tools/28.0.3

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.

./zipalign -v 4 /Users/greg/Desktop/AppLocal/myapp/platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk /Users/greg/Desktop/AppLocal/myapp/platforms/android/app/build/outputs/apk/release/app-release.apk

Hope it helps.

鹿童谣 2024-10-29 03:50:00

搜索它并引用它...我在这里有它并像这样引用它:

/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

愿与i 2024-10-29 03:50:00

放松! ,只要在终端中使用Locate命令无论它在哪里,它就会出来

tom-MacBook-Air:kavform_app tom$ locate zipalign

/Users/tom/Software/android-sdk-macosx/build-tools/24.0.1/zipalign

/Users/tom/Software/android-sdk-macosx/docs/tools/help/zipalign.html  

在我的例子中它被埋在这里

/Users/tom/Software/android-sdk-macosx/build-tools/24.0.1/zipalign -v 4 /Users/tom/kavwork/kavform/kavform_app/platforms/android/build/outputs/apk/android-release-unsigned.apk BrideToBe.apk

Relax! , Just Use Locate Command in Terminal WHEREVER it is , it will come out

tom-MacBook-Air:kavform_app tom$ locate zipalign

/Users/tom/Software/android-sdk-macosx/build-tools/24.0.1/zipalign

/Users/tom/Software/android-sdk-macosx/docs/tools/help/zipalign.html  

In my case it was burried over here

/Users/tom/Software/android-sdk-macosx/build-tools/24.0.1/zipalign -v 4 /Users/tom/kavwork/kavform/kavform_app/platforms/android/build/outputs/apk/android-release-unsigned.apk BrideToBe.apk
酒与心事 2024-10-29 03:50:00

路径

将其添加到终端上的

查找 zip 对齐路径的

find ~/Library/Android/sdk/build-tools -name "zipalign"

路径: /Users/username/Library/Android/sdk/build-tools/26.0.1/zipalign

输入在那里找到的路径

sudo nano /etc/paths

现在在新终端上您可以看到 zipalign reco

add it to the path

on terminal

find path for zip align

find ~/Library/Android/sdk/build-tools -name "zipalign"

path: /Users/username/Library/Android/sdk/build-tools/26.0.1/zipalign

enter the path found in there

sudo nano /etc/paths

now on new terminal you can see zipalign reco

酒与心事 2024-10-29 03:50:00

Mac 的解决方案

此错误基本上意味着终端无法找到 zipalign 文件。
因此,您可以使用命令(位于 Android build-tools 文件夹中)输入 zipalign 文件的完整路径。

/Users/username/Library/Android/sdk/build-tools/26.0.1/zipalign -v 4 android-armv7-release-unsigned.apk helloWorld.apk;

如果您不知道 zipalign 文件的位置,则只需使用此命令

find ~/Library/Android/sdk/build-tools -name "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)

/Users/username/Library/Android/sdk/build-tools/26.0.1/zipalign -v 4 android-armv7-release-unsigned.apk helloWorld.apk;

If you do not know the location of the zipalign file, then just use this command

find ~/Library/Android/sdk/build-tools -name "zipalign"
傾城如夢未必闌珊 2024-10-29 03:50:00

如果您使用的是 Windows,请将命令提示符更改为指向包含 zipalign.exe 的文件夹,然后运行该命令。另外,我发现您没有使用完整的命令:

zipalign [-f] [-v] 4 Input.apk Output.apk

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:

zipalign [-f] [-v] 4 Input.apk Output.apk
婴鹅 2024-10-29 03:50:00

cd android-sdk/build-tools/22.0.0/ - 将目录更改为 android sdk 文件夹,构建工具并选择版本(我使用的是 22.0.0)。

然后在提示符处输入:

./zipalign -v 4 /MyApp/android-x86-release-signed.apk ~/MyApp/android-x86-release-signedandzipped.apk

这对我有用。我尝试了上面的其他解决方案,但没有成功。我只需在正确的文件夹中运行命令,但在我检查的其他资源中没有清楚地解释这一点。

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:

./zipalign -v 4 /MyApp/android-x86-release-signed.apk ~/MyApp/android-x86-release-signedandzipped.apk

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.

方圜几里 2024-10-29 03:50:00

导航到 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

裂开嘴轻声笑有多痛 2024-10-29 03:50:00

或者,如果您不想将特定的构建工具文件夹添加到路径中,以防将来它发生变化,您可以使用 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.

七分※倦醒 2024-10-29 03:50:00

对我来说,这工作得很好,我将 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

小矜持 2024-10-29 03:50:00
%ANDROID_HOME%\\build-tools\\25.0.2\\zipalign -v 4 .\\platforms\\android\\build\\outputs\\apk\\input.apk .\\path\\ output.apk
%ANDROID_HOME%\\build-tools\\25.0.2\\zipalign -v 4 .\\platforms\\android\\build\\outputs\\apk\\input.apk .\\path\\ output.apk
佼人 2024-10-29 03:50:00

第一的,
如果你的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.

萌辣 2024-10-29 03:50:00

从 github 下载 zipalign 文件

zipalign exec copy and paste in your Project1-aligned.apk directory
./zipalign -v 4 Project1.apk Project1-aligned.apk

Downloaded zipalign-file from github

zipalign exec copy and paste in your Project1-aligned.apk directory
./zipalign -v 4 Project1.apk Project1-aligned.apk
天赋异禀 2024-10-29 03:50:00

就我而言
我遵循以下答案

  1. 更改目录

    /path/to/sdk/build-tools//zipalign

  2. 类型

    ./zipalign 而不是 zipalign

简而言之 ./zipalign 是我的解决方案。

In my case
I follow below answer

  1. Change directory

    /path/to/sdk/build-tools//zipalign

  2. Type

    ./zipalign instead zipalign

In short ./zipalign is solution for me.

空宴 2024-10-29 03:50:00

Jenkins 解决方案

对于使用 MacOS 构建和签名移动应用程序的 Jenkins 用户遇到此错误,解决方案可能是这样的:

在进行签名的阶段:

withEnv(['PATH=/Users/jenkins/Library/Android/sdk/build-tools/29.0.3', 
'ANDROID_SDK_ROOT=/Users/jenkins/Library/Android/sdk', 
'JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home'])

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:

withEnv(['PATH=/Users/jenkins/Library/Android/sdk/build-tools/29.0.3', 
'ANDROID_SDK_ROOT=/Users/jenkins/Library/Android/sdk', 
'JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home'])
吻泪 2024-10-29 03:50:00

我使用的是 Windows,

需要在环境变量中配置 git bash/command promt zipalign.exe。

因此,请包含 sdk 文件夹“build-tool”以及您用于构建的 Android 版本文件夹。

e.g. E:\android-sdk\build-tools\22.0.1

它应该包含“zipalign.exe”。现在您可以

zipalign -v 4 Project1.apk Project1-aligned.apk

使用命令行工具从任何位置进行用户操作。

为我点赞,这样我就可以帮助更多的开发者。

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.

e.g. E:\android-sdk\build-tools\22.0.1

it should contain 'zipalign.exe'. now you can user

zipalign -v 4 Project1.apk Project1-aligned.apk

from any location using command line tools.

thumb up for me so i can help more developers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文