14 marca 2018

Edycja paczek Androida .apk i podpisywanie

Szybki wpis opisujący jak wyedytować i podpisać plik .apk

Było mi to potrzebne ze względu na błąd:

Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: Package couldn’t be installed in /data/app/com.android.stk-1: Package com.android.stk has no signatures that match those in shared user android.uid.phone; ignoring!]

  1. Decompile the apk file using apktool(https://bitbucket.org/iBotPeaches/apktool/downloads/):
    1. java -jar apktool.jar d example.apk
  2. Make the changes needed – my app needed permissions, so I wanted to remove sharedUserId from AndroidMainfest.xml:
    1. remove android:sharedUserId= …
  3. Recompile the source code into a new apk:
    1. java -jar apktool.jar b -o example_my.apk example
  4. Create a signing key; Skip this step if you have created one already. Note: keytool is located in the Java SDK directory (e.g. C:\Program Files (x86)\Java\jdk1.8.0_161\bin)
    1. keytool -genkey -v -keystore myAndroidKey.keystore -alias myAndroidKeyAlias -keyalg RSA -keysize 2048 -validity 10000
  5. Sign your new apk
    1. jarsigner -verbose -keystore myAndroidKey.keystore ./example_my.apk myAndroidKeyAlias
  6. (Optional) Use zipalign to align your apk.
    1. zipalign -v 4 Reader_my.apk Reader_my_zipaligned.apk

 

based on:

  1. https://forum.xda-developers.com/showpost.php?p=37343918&postcount=2
  2. https://stackoverflow.com/questions/3997748/how-can-i-create-a-keystore

TrackBack

TrackBack URL dla tej wiadomości:
https://blog.kkthx.pl/2018/03/edycja-paczek-androida-apk-i-podpisywanie/trackback/

Napisz komentarz