The problem

When we access and debug the third-party SDK, the third-party SDK often requires us to set the signature on their platform and use the signature when packaging output, so that we can use the related functions of the third-party SDK, such as the authentication and sharing functions of wechat.

However, in a real production environment, the signature file itself is a relatively important confidential file that only exists on the packager and is not distributed to the development brother’s machine. Some platforms provide a debug keystore for testing, but this keystore is missing due to unverifiable reasons.

Therefore, we have experienced in the past, in order to debug third-party related content, every piece of code, put it in a remote build, and then use the release package to check the effect, not only inefficient, but also can not break debugging.

The solution

In fact, this problem is very simple, we just use the existing keystore, generate a debug keystore, and create a new task on the packaging machine, just upload the debugApk each time, and use the debug keystore to re-sign. This allows you to quickly test third-party SDK-related content.

Step 1: Create the keystore

1) Make a copy of the release keystore. Let’s call it my.keystore

2) Change the keystore password

keytool -storepasswd -keystore my.keystore
Copy the code

You will be prompted to enter the old password, and the new password, the new password changed to Android

3) Change the alias of the keystore

keytool -changealias -keystore my.keystore -alias my_name -destalias androiddebugkey
Copy the code

My_name is the name of the old alias. Note that this step is to change alias to AndroidDebugkey. It will prompt you to enter the keystore password and alias password. The alias password is still old

4) Change the password of the alias

keytool -keypasswd -keystore my.keystore -alias androiddebugkey
Copy the code

This will prompt you to enter the keystore password, alias password, and the new alias password. Note that the keystore password is already Android, and the alias password is still the old one

This completes the keystore

Step 2: Re-sign

Since our build environment is deployed on Jenkins, this is for Jenkins’ job, and it should be similar for other CI environments.

Create a job and add a File Parameter to upload the debugApk. The Parameter name is source.apk. This file will be stored at ${Wordspace}/source.apk

Job Compile Execute the following script

unzip source.apk -d workdir cd workdir rm -rf META-INF zip -r .. /target.apk * cd .. jarsigner -digestalg SHA1 -sigalg MD5withRSA -keystore /your/path/to/my.keystore -storepass android -keypass android target.apk androiddebugkeyCopy the code

Note the keystore path in the replacement script

This results in a target.apk file, which is a signed APK file, and is fun to debug

Refer to the link

Blog.csdn.net/qq_31046737…

www.yeetrack.com/?p=973