androidapkjarsigner

Can you force jarsigner to us forwards slashes?


I have an android APK file, which I need to unzip, replace one file, re-sign using jarsigner and then zipalign to a valid APK.

The app installs without errors, but when run it cannot find the first thing it looks for in the /assets/ folder. The required file is definitely in the APK, in the right place, etc.

"An error has occurred in sub:main_activity_create(Jave line:375) java.io.FileNotFoundException:control.bal"

The differences I can see is that the original Manifest.MF file has forward slashes (U+002F), but when I run jarsigner on the server it creates a new manifest.mf with backward slashes (U+005C). Is there a way of making jarsigner use forward slashes?

Code is C# .NET running on an Azure server.

Orignal Manifest.MF format:

Manifest-Version: 1.0
Created-By: 1.8.0_112 (Oracle Corporation)

Name: assets/longblackbar.png
SHA1-Digest: 1Fq7U1Y/dLAVflFmTzLcC0tvKu4=

Re-signed Manifest.MF format

Manifest-Version: 1.0
Created-By: 1.7.0_51 (Oracle Corporation)

Name: assets\longblackbar.png
SHA1-Digest: vaky9S8cGhJIvh7a4LmmtWOpqAg=

Solution

  • Turns out the answer is that the C# ZipFileExtensions method is the cause of the problem, creating backslashes. If I replace that with running 7za.exe as a process then forward slashes are used, and thereafter everything works fine.