Signing an 3rd partry apk with v2 signing scheme

289 Views Asked by At

Recently I have been trying to debug a 3rd party android application using a variery of tools. I have followed the directions in this video. These were the main steps presented in the attached video:

  1. deassemble the original apk - apktool (2.6.1)
  2. Change/Add the android:debugaable='true' property in the AndroidManifest.xml file - Manually.
  3. build an unsigned apk using the previous level directory - apktool (2.6.1).
  4. sign the apk - dex2jar.d2j-apk-sign (2.2-SNAPSHOT)
  5. Install the app into an emulator on android studio (*emulator stats are described below) - using adb on android sdk.

However, I have faced trouble in signing and installing the apk in the emulator. I have tried a variety of tools and options in order to fix the issue:

  1. Using d2j-apk-sign - The signing itself seemed to have worked, but the installion didn't.

    I received the error:

    adb: failed to install C:\Users\user\Desktop\Moovit_Stuff\chess_signed.apk: Failure [-124: 
    Failed parse during installPackageLI: Targeting R+ (version 30 and above) requires the 
    resources.arsc of installed APKs to be stored uncompressed and aligned on a 4-byte boundary]
    
  2. Using zipalign and apksigner (sdk 33.0.0) - I have used the information on this. accrroding to KJ7LNW's comment there, zipalign should be used and then a different tool named apksigner. zipalign worked perfectly, but afterwards, apksigner requires a keystore file. I have created one in android studio (jks file), but after using it received the following error.

    Failed to load signer "signer #1"
    java.io.IOException: Invalid keystore format
            at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
            at sun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)
            at sun.security.provider.KeyStoreDelegator.engineLoad(Unknown Source)
            at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(Unknown Source)
            at java.security.KeyStore.load(Unknown Source)
            at com.android.apksigner.SignerParams.loadKeyStoreFromFile(SignerParams.java:362)
            at     
    com.android.apksigner.SignerParams.loadPrivateKeyAndCertsFromKeyStore(SignerParams.java:248)
            at com.android.apksigner.SignerParams.loadPrivateKeyAndCerts(SignerParams.java:181)
            at com.android.apksigner.ApkSignerTool.getSignerConfig(ApkSignerTool.java:419)
            at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:336)
            at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:92)
    

    I have tried to change the extension to .keystore but it didn't work either.

  3. (2.1) Using r0adkll's comment on this - in order to fix the keystore file. (using openssl base64, didn't change the result)

if you have reached this point, I want to thank you and I would greatly appreciate it if you could try and assist me.

Thanks in advance!

**Notes:

  1. apk file that I used - here
  2. emulator stats - Pixel & android tiramisu (version 33, x86_64)
0

There are 0 best solutions below