Greg
Greg

Reputation: 93

How to rezip an APK file?

I have 2 APK files, both just different versions of the same project. I need to replace some pictures and layout xml pages in the RES folder of one of them using the files from the other.

While I can unzip both of them no problem in Windows 7, my Android phone doesn't finish the installation of the new APK if even one file was replaced. If I unpack and rezip the APK file without any changes, it installs correctly. I use WinRar to zip the files into a ZIP file, then renamed it APK.

What am I missing here?

Upvotes: 3

Views: 5361

Answers (2)

Alex Martian
Alex Martian

Reputation: 3782

Keep in mind certificate from Greg answer is old. Strangely apk installs signed with certificate that is valid till 2013 (at least for one I found following attached tutorial).

You may sign with certificate generated by yourself via say Android Studio. Use jarsigner from Java SDK (search Internet for guide to sign apk).

Upvotes: 0

Greg
Greg

Reputation: 93

It appears that just zipping up the files is not enough. You need to sign the zip file afterwards for Android. It’s basically just Step 5 from this tutorial:

  1. Unpack "sign-apk.rar" or "SignApk.zip" (provided in tutorial)
  2. Put your ziped new apk into signapk.jar folder
  3. Open cmd and go to the folder thorough CD command
  4. Run cmd command: java -jar signapk.jar certificate.pem key.pk8 your-apk-file.apk output-apk-file.apk

To save time you can keep your “your-apk-file.apk” as zip file for step 4 above. You could also skip step 2 and use long full addresses in step 4, but that just a hassle. And you don’t need to rename the final file of “output-apk-file.apk” – it should install regardless of the file name.

Upvotes: 1

Related Questions