Android APK method of removing signature and re signing

Android APK method of removing signature and re signing

A very important part of Android development is to sign APK files with your own key. APK files without signature can not be installed. Even if they are installed, they will fail in the end.

The "check to allow the installation of applications from unknown sources" circulating on the Internet actually has nothing to do with whether to sign or not. In short, it is to allow the installation of applications that are not downloaded from the electronic market.

In recent days, we need to modify a. So file called by JNI in APK. Because there is no APK source code, we have to study the problems related to signature. Of course, there are many third-party tools that can do this, but in fact, a powerful signature tool jarsigner has been provided in JDK.

1. remove signature

In fact, it's very simple. Open APK with WinRAR, find the meta-inf folder, and delete all other files except manifest.mf.

2. Signature

Run jarsigner. If the path environment variable is not set, you can find it in the bin directory under the JDK installation path. For example, my native is C: \ program files \ Java \ jdk1.8.0_ 31\bin\jarsigner.exe

Jarsigner is used as follows:

The commonly used parameters are to specify the location of the keystore and the signed file, for example:

The file to be signed is apk-unsigned.apk, and the signed APK is apk-signed.apk. We can also sign directly on the APK to be signed without specifying the - signedjar parameter. The last MyKey is the alias of my keystore.

After signing, open it with WinRAR. You will find mykey.rsa and mykey.sf files in the meta-inf directory. They are:

SHA-1 of all other files and Base64 encoded values are saved in manifest.mf. Mykey.sf also has the value of SHA-1 and Base64 encoding of other files, and there is also an additional value of SHA-1 and Base64 encoding of manifest.mf file. Mykey.rsa contains the public key information and publisher information

The names of the last two files are consistent with my key alias after being converted to uppercase.

I won't repeat how to generate a native keystore. There are corresponding tools in Android studio and eclipse, graphical interface, so easy.

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>