APK modification
First, decompile apk file with apktool:
apktool d <file_name>.apk
Replace assets or edit Manifest.xml. smali2java can be of use for code modifications.
Recompile apk:
apktool b <file_name>
Alignment is necessary for modern android versions (I believe, 30+ SDK):
zipalign -v -f -p 4 <file_name>/dist/<file_name>.apk aligned-<file_name>.apk
Create a signing key. Fields values do not matter. Especially for personal use.
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 1000
Actually sign apk with it:
apksigner.jar sign -ks my-release-key.keystore --ks-key-alias alias_name aligned-<file_name>.apk
It will overwrite the provided apk with a signed one.
We're awesome!