got this one working, with the help of aapt.
Basic approach is to insert a file in assets in apk on the fly.
requires:
- a web-server able to serve apk e.g. apache, add mime types for apk in web-server config files.
- a server side script which can execute shell commands e.g. php, jsp
- an unsigned-apk, unsigned coz aapt seems to have some problem with modification of signed apks and then again resigning them.
- android and java sdk on serving machine
then:
As soon as user clicks on the download link hosted on your web-site, record an entry in a db, with some field describing the state as downloaded/downloading.
generate your text property file to be inserted inside assets folder in apk. use aapt to add it to apk.
aapt remove app.apk "assets/tracker.txt"
aapt add app.apk "assets/tracker.txt"
directory structure where source apk will be hosted like this : ROOT-> (assets ->(app_tracker.txt)) + app.apk
after this signing
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -storepass STORE_PASSWORD -keystore KEYSOTRE_PATH alias_name
NOTE: you should not modify the source app.apk and tracker.txt, what you should is to copy it to some relative path and then do modification over it.
hope it helps, it helped me though :)