Compiling the apk file at web server

1.4k Views Asked by At

I want to create a system where a user does sign in to my website and then gets a link to download apk for my android app. Inside the app there is a final string containing username by which the server recognises the app. For this purpose I want my server to compile a fresh apk with the username inside for each user. I have no idea how to achieve this please help.

edit- basically the problem comes down to this, is there any way to compress certain file into .rar programmatically . And which language should i use for this.

2

There are 2 best solutions below

0
On

Extracted from Documentation

The following diagram depicts the components involved in building and running an application:

enter image description here

More details: Building Your Project with Gradle

0
On

This is very possible as long as you don't mind spending the server resources because the system will need to package the entire apk and sign it each time. Not sure what environment you are programming in but for instance if you are using ionic.

Simply have the file for your username string stored somewhere such as c:\dev\app\www\username.php - you would update this before you run a batch file to build the application

batch would be something like

cd C:\dev\ionic\app\ 
ionic build --release android
C:\dev\Java\jdk1.8.0_20\bin\jarsigner -storepass YOURPASSWORD -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore C:\dev\ionic\app\platforms\android\ant-build\myApp-release-unsigned.apk alias_name
C:\dev\android\sdk\build-tools\android-4.4W\zipalign -f -v 4 C:\dev\ionic\app\platforms\android\ant-build\myApp-release-unsigned.apk myApp.apk

run this using system() in php and you will end up with your apk at the end which you can send down the line to your client. This is a bit convoluted and seeing as how you are making users sign in to the website why not do it the other way around and have the app sign in?