Reputation: 647
Well, I know the title is not well-written, but my case is as complicated as that! I searched for this case here but other similar questions really differ from mine.
Here is my problem:
Now what is best solution to do this and which tools and commands I should use? I mean which tools (aapt, jarsigner, ...) I should include in my software and which commands must be launched by my software to do this?
More info about my case:
P.S: OK, after some hours I nearly found solution in 9 steps and got final custom-signed-zip-aligned apk file and installed on device without errors! But now the problem is: all of apk files that would be produced by my users would have same package name (com.MyName.MyApp) and would cause problem if someone installs 2 or more of them on their phones. Should I try "aapt --rename-manifest-package" for this problem? and how to use it?
Upvotes: 0
Views: 2623
Reputation: 647
I finally have ended up with this working solution, I put it here for anyone interested.
1- Extract "original.apk" (source.apk) to a temp folder (ie. TempFolder)
2- Put user-generated files in "assets" and "res\drawable" folders under TempFolder
3- generate AndroidManifest.xml and put in TempFolder
4- Run this command: aapt package -f -M "PathToManifest" -S "PathToResFolder" -I android.jar -F "NearlyFinal.apk" -A "PathToAssetsFolder"
5- copy "classes.dex" to folder where NearlyFinal.apk exists.
6- run this command: aapt add -f NearlyFinal.apk classes.dex jad.properties
7- sign apk file: jarsigner -storepass [keystorePass] -keystore KeyStoreFile.key NearlyFinal.apk [KeyStoreName]
8- zipalign apk file: zipalign 4 NearlyFinal.apk "Final.apk"
9- rename and move Final.apk according to user's pref's.
FINISH
Upvotes: 4