53

Can anyone tell me how to zipalign my .apk file with using eclipse. I have made my .apk file by giving command like,

  1. Right Click on Project Folder

  2. Click on "Android Tools" option from menu.

  3. Click on "Export Signed Application Package..." and my .apk generated in given application alias.

Now want to do zipalign for this above generated .apk file. Does any tool require to do so OR anything that can solve my problem.

Tej Zaveri
  • 567
  • 1
  • 4
  • 8

8 Answers8

47

If you did what you described above then Eclipse has already zipaligned your apk for you. You can't zipalign an already zipaligned package

apesa
  • 12,163
  • 6
  • 38
  • 43
  • 1
    very true. In eclipse, no further process is required since the export wizard zip aligns the apk automatically. – Akah Dec 05 '14 at 08:14
  • But only if you export a signed apk. An unsigned apk will not be aligned – Twilite Aug 08 '16 at 12:43
38

I think this will help you

D:\android-sdk\android-sdk\tools>zipalign -f -v 4 "C:\Users\name\Desktop\project_name\projectname_signed.apk" "C:\Users\name\Desktop\project_name\projectname__zipaligned.apk"
Muhamed Riyas M
  • 5,055
  • 3
  • 30
  • 31
  • 1
    @Tamawy : Here 4 stands for that must be always be 4 (which provides 32-bit alignment) or else it effectively does nothing.You can refer "http://developer.android.com/tools/help/zipalign.html" – Muhamed Riyas M Jul 24 '14 at 06:30
7

Using the steps given, Eclipse will do zipalign for you.

Anthony
  • 12,177
  • 9
  • 69
  • 105
SteelBytes
  • 6,905
  • 1
  • 26
  • 28
5

This is a very tricky part and initially i was also ran in to strange problems . Before uploading to android market you must do the following steps.

  • Create a Certificate
  • Signing your application apk
  • Finally Zip align the signed apk

Check this site: How to sign Android project apk

droid kid
  • 7,569
  • 2
  • 32
  • 37
3

Eclipse zipalign APKs when you export them by default.

zipalign is basically a tool available in tools directory of your android sdk.

In case you are not using eclipse to build, you can use this tool directly to zipalign your apk.

zipalign [-f] [-v] <alignment> infile.apk outfile.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.

For more detail, check this link http://developer.android.com/tools/help/zipalign.html

Pratap Singh
  • 4,607
  • 1
  • 22
  • 24
1

If you to signed and zip aligned your APK file, so that you could redistribute your file and upload it play store. Then follow these simple steps

  • Open Eclipse
  • File--> Export
  • Browse-->Select your project
  • Next-->Next

So, after all of that you will get an APK which will be signed and zip aligned.

Pir Fahim Shah
  • 10,505
  • 1
  • 82
  • 81
0

Eclipse zipalign apk automatically. When you export the project, eclipse must be generating signed apk to a different destination. Check properly where it prompts when you generate a signed apk

user2780638
  • 2,503
  • 2
  • 13
  • 8
0

Eclipse automatically zipaligns your .apk file if you did what you described above.

fidazik
  • 423
  • 1
  • 5
  • 11