0

I'm attempting to re-sign an Android .apk. i.e. It is currently self signed and I wish to re-sign it with the official certificate.

To do this I

  1. Download the build archive
  2. Rename it from name.apk to name.zip
  3. Extracting the zip
  4. Delete META-INF
  5. Zip back up the directory
  6. Rename the .zip back to .apk
  7. Sign the .apk with the official keystore using jarsigner
  8. Run zipalign against the signed .apk

But when I upload and run the .apk to a mobile it crashes when launched. This is caused by the following error

Caused by: android.content.res.Resources$NotFoundException: File res/raw/my_file.wav from drawable resource ID #0x7f070002
Caused by: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed

Sure enough when I check the console log I can see that zipalign is compressing this file

res/raw/my_file.wav (OK - compressed)

it should be doing this

res/raw/my_file.wav (OK)

How can I get zipalign is not compress my .wav files? Based on this answer Android should not be compressing .wav files.

FileReader csv : FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed

I've also noticed a warning before running zipalign. i.e. It appears after I run jarsigner

No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2043-01-30) or after any future revocation date.

What causes this message to appear? Seems likely that it is related.

Community
  • 1
  • 1
Shane Gannon
  • 6,770
  • 7
  • 41
  • 64

2 Answers2

0

There is a limitations on opening compressed files in the assets folder. This is because uncompressed files can be directly memory mapped into the processes virtual address space, therefore avoiding needing the same amount of memory again for decompression. You can read this article to hava a reference.

TanLingxiao
  • 402
  • 5
  • 7
-1

Got the solution from a work colleague. Basically I should not be extracting the archive. To work around this I did the following

  1. Download the build archive
  2. Rename it from name.apk to name.zip
  3. Delete META-INF from name.zip

e.g.

7z d name.zip META-INF
  1. Rename the .zip back to .apk
  2. Sign the .apk with the official keystore using jarsigner
  3. Run zipalign against the signed .apk
Shane Gannon
  • 6,770
  • 7
  • 41
  • 64