Search code examples
androidapkandroid-install-apk

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


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).


Solution

  • 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.