1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

apktoolでリコンパイル&jarsignerで署名したアプリのインストールにコケたけど解決した話

Posted at

いきなりまとめ

  • apktoolでdecompile & recompileしてjarsignerで署名してadb install app.apkしたけどコケた
  • Android11からはapk署名スキームv2を使う必要あり
  • そのためにはjarsignerではなくapksignerを使う

おさらい

apktoolでdecompile & recompile

まずはデコンパイル。
apktool d targetapp.apk
次にリコンパイル
apktool b targetapp -o output.apk
[備忘録]自分がよくやるデコンパイル・リコンパイルの間の作業

AndroidManifest.xmlの編集
追加:android:networkSecurityConfig="@xml/network_security_config" 
追加:android:debuggable="true#

追加:res/xml/network_security_config.xml
<network-security-config>
    <base-config>
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
    <debug-overrides>
        <trust-anchors>
            <certificates src="user" />
        </trust-anchors>
    </debug-overrides>
</network-security-config>

署名する

署名に使う証明書作成
keytool -genkey -v -keystore test.keystore -alias TEST -keyalg RSA -validity 10000
jarsignerでの署名
jarsigner -verbose -keystore test.keystore app.apk TEST
apksignerでの署名
apksigner sign --ks test.keystore -v --v2-signing-enabled true --ks-key-alias TEST app.apk

※各種ツールの細かい使い方はヘルプ参照。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?