How to insert unique data into an Android APK package with each download?

305 Views Asked by At

Goal: To embed info from HTTP headers into an APK package, on-the-fly, during download.

Situation: There is an APK package the company website, available for public downloads. A user comes to the download page, and the server grabs the referring URL, and landing page URL. What we need is, for the URLs to be included inside the package, so that when the app is installed and user creates an account using the app, the URL info is available to the app and appened to the newly created account details (for purposes of traffic analysis and marketing attribution).

2

There are 2 best solutions below

3
Francesco Re On BEST ANSWER

An APK is fundamentally an archive.

I think that you should be able to unzip, edit and zip it again without changing its signature, as you can see from this detailed guide

In order to put a unique code inside your app, you could use the assets folder creating a txt or json file containing that code.

Then, you can retrieve the unique code inside your app by reading the assets folder programmatically.

2
Sintuz On

To change the apk, you would need to change the code and recompile it. It’s not possible to modify the content of a compiled apk.