How to zipalign the apk file in Windows

元气小坏坏 提交于 2019-12-20 10:26:19

问题


I have signed and packaged the Xamarin application
and so have created the apk file using Visual Studio.

How can I zipalign this file in Windows?


回答1:


Make sure you have the Android SDK build-Tools installed then check where your SDK is installed mine was at C:\Program Files(x86)\Android\android-sdk\build-tools\23.0.1\zipalign You will find zipAlign in the android build tools then use it like so:

C:\Program Files(x86)\Android\android-sdk\build-tools\23.0.1\zipalign -v 4 infile.apk outfile.apk

Usage

To align infile.apk and save it as outfile.apk:

zipalign [-f] [-v] <alignment> infile.apk outfile.apk

To confirm the alignment of existing.apk:

zipalign -c -v <alignment> existing.apk

The alignment is an integer that defines the byte-alignment boundaries. This must always be 4 (which provides 32-bit alignment) or else it effectively does nothing.

Flags:

-f : overwrite existing outfile.zip

-v : verbose output

-c : confirm the alignment of the given file

output from windows (extra parameters not in the Docs :O) :

Zip alignment utility
Copyright (C) 2009 The Android Open Source Project

Usage: zipalign [-f] [-p] [-v] [-z] <align> infile.zip outfile.zip
       zipalign -c [-v] <align> infile.zip

<align>: alignment in bytes, e.g. '4' provides 32-bit alignment
-c: check alignment only (does not modify file)
-f: overwrite existing outfile.zip
-p: page align stored shared object files
-v: verbose output
-z: recompress using Zopfli

ZipAlign Docs




回答2:


I spent a good few minutes searching for the Android command line build tools. They were nowhere to be found inside either of the Program Files directories. Apparently, on my system the tools were in the following location:

C:\Users\{username}\AppData\Local\Android\Sdk

I found the location inside Android Studio by going to File > Project Structure > SDK Location.

Edit: Obviously, "my system" is Windows - specifically Windows 10.




回答3:


for win10 its in c:\Users, such as: C:\Users\\Android\sdk\build-tools\




回答4:


For windows 10 set PATH variable to

C:\Users\<NAME>\AppData\Local\Android\Sdk\build-tools\<version>

And then run the command from the location where application is present

zipalign -v 4 <YOUR_APP_NAME> app-release-final.apk



回答5:


On my end, the path it's quite different, i installed android studio, which created the following path:

C:\Users\<Username>\AppData\Local\Android\Sdk\build-tools\<VERSION>\zipalign.exe

Just direct to that path and run the command, make sure to use full path of where your file is located...

Hope that helps.



来源:https://stackoverflow.com/questions/36916462/how-to-zipalign-the-apk-file-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!