Other Downloading config along with the application

gregmatthews

Member
Licensed User
Hi,
Not sure if this is really the right place to ask this kind of question, but I'm stuck and need the help.

I've used b4a to create an application, nicely packaged into a *.apk

I need to give each business customer a unique URL where their employees can download the application along with a config file holding an API Key specific to that business. How?

(1) I can put a key in the manifest.xml, but this is compiled at build time, and whilst the *.apk can be unzipped, I would need to compile a new manifest.xml with the new key and re-sign the apk.
(2) Can I include a file in the res folder? I can then swap this out in the *.apk (zip file), but would I still need to re-sign the apk? probably

NB: the solution of the user going to website and fetching the api key for them is not appropriate for this solution.

Help!
G.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is how you can do it:
Create a batch file or a B4J console program that copies the configuration file to the project Files folder and compiles the project with B4A command line builder.
The command line builder allows you to set the APK name.

This will allow you to create an APK for each customer with his own configuration.
 
Upvote 0

gregmatthews

Member
Licensed User
Hi Erel,
I'd have to install B4a on the Azure server, so trying to avoid that complexity.
Can I store a file in assets/ e.g. assets/api_key.xml
I can then hold the *.apk unzipped on the server, swap in a new api_key.xml and Zip it?
[I suspect I may have to re-sign the apk?]
That saves installing the b4a tools on the server, and means 'all' I need is Zip
I need to find some sample code for opening the file in the assets folder, I'm presuming something like this
 
Upvote 0

gregmatthews

Member
Licensed User
Just to tie up loose ends of what looks to be a working solution
1. Created the APK using b4a
2. Unzipped it and deleted the META-INF folder
3. Stored the unzipped files/folders on the server
4. Dynamically created an ApiKey.xml at run-time and dropped it into the Assets folder
5. Zipped up the folders to a *.APK
6. Ran jarsigner on the APK
7. Ran Zipaligner

All seems to work locally, so next steps are to
(1) drop it onto Azure
(2) Add a layer of encryption (done in .NET just working on the decrypt in B4A now...)
 
Upvote 0
Top