Giter Site home page Giter Site logo

zipalign's Introduction

ZipAlign

A Go replacement for Android's SDK ZipAlign tool. See https://developer.android.com/studio/command-line/zipalign.html for more information.

When signing an APK with jarsigner, the returned zip is not aligned properly. Android optimizes APK by aligning each file on 4 bytes to load them with mmap. Running zipalign on an unaligned APK fixes its padding in the headers of each entry to align it properly.

Installation: go get github.com/mozilla-services/zipalign

Usage: zipalign -a 4 -i infile.zip -o outfile.zip

Example

The command below takes a signed unaligned apk and fixes its padding. Verbosity is reduced to only show files that require padding. The aligned APK is then verified with Android's original zipalign tool to make sure the alignment is correct per Android standard.

$ zipalign -i ~/app-rocket-webkit-release-1816-signed.apk -o /tmp/rocket-aligned.signed.apk -v 2>&1| grep padding

2018/01/11 08:16:59  --- res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png: padding 3 bytes
2018/01/11 08:16:59  --- res/drawable-hdpi-v4/design_ic_visibility.png: padding 1 bytes
2018/01/11 08:16:59  --- res/drawable-hdpi-v4/googleg_disabled_color_18.png: padding 3 bytes
2018/01/11 08:16:59  --- res/drawable-hdpi-v4/home_pattern.png: padding 1 bytes
2018/01/11 08:16:59  --- res/drawable-hdpi-v4/ic_notification.png: padding 3 bytes
2018/01/11 08:16:59  --- res/drawable-hdpi-v4/logotype.png: padding 1 bytes
2018/01/11 08:16:59  --- res/drawable-mdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png: padding 3 bytes
2018/01/11 08:16:59  --- res/drawable-mdpi-v4/design_ic_visibility.png: padding 1 bytes
2018/01/11 08:16:59  --- res/drawable-mdpi-v4/googleg_disabled_color_18.png: padding 3 bytes
2018/01/11 08:16:59  --- res/drawable-mdpi-v4/notification_bg_low_normal.9.png: padding 1 bytes
2018/01/11 08:16:59  --- res/drawable-xhdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png: padding 3 bytes
2018/01/11 08:16:59  --- res/drawable-xhdpi-v4/design_ic_visibility.png: padding 1 bytes
2018/01/11 08:16:59  --- res/drawable-xhdpi-v4/googleg_disabled_color_18.png: padding 3 bytes
2018/01/11 08:16:59  --- res/drawable-xhdpi-v4/notification_bg_low_normal.9.png: padding 1 bytes
2018/01/11 08:16:59  --- res/drawable-xxhdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png: padding 3 bytes
2018/01/11 08:16:59  --- res/drawable-xxhdpi-v4/design_ic_visibility.png: padding 1 bytes
2018/01/11 08:16:59  --- res/drawable-xxhdpi-v4/googleg_disabled_color_18.png: padding 3 bytes
2018/01/11 08:16:59  --- res/drawable-xxhdpi-v4/home_pattern.png: padding 1 bytes
2018/01/11 08:16:59  --- res/drawable-xxhdpi-v4/ic_notification.png: padding 3 bytes
2018/01/11 08:16:59  --- res/drawable-xxhdpi-v4/logotype.png: padding 1 bytes

$ /opt/android-sdk/build-tools/27.0.3/zipalign -c -v 4 /tmp/rocket-aligned.signed.apk
...
Verification succesful

zipalign's People

Contributors

jvehent avatar

Stargazers

 avatar  avatar Iqbal Rifai avatar Иван Тимашков avatar dosgo avatar X-ray avatar Scott avatar Song Liu avatar  avatar Alexey Terentev avatar Leo Lamas avatar Gal Tashma avatar Imran Ansari avatar

Watchers

 avatar James Cloos avatar Mark Reid avatar Miles Crabill avatar  avatar

zipalign's Issues

CODE_OF_CONDUCT.md file missing

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please reach out to [email protected].

(Message COC001)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.