How to add/edit/change files in Android APK file?

How to modify files which are already packaged into a apk file? For example, you want to change some configuration but don't want to rebuild the project again.

I found the aapt command is pretty useful. For example, I want to change user_info.txt in assets folder, I can do like this:
aapt remove -v yourapkfile.apk assets/user_info.txt
aapt add -v yourapkfile.apk assets/user_info.txt

But, if you modify any file inside a signed APK file, you need to sign it again so that it can be installed. You can sign your apk file by using jarsigner, for example, 
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore yourkeystore.file $1 alias <<< password

Comments

Post a Comment