dar-alatta / docs/build_android.md
Build app for Android
Dar Al Atta's application and website
Build app for Android
This is a guide on how to build the Android version of the app for production. It is based on this guide:
Prerequisites
- Must have Java version 21 installed. Version 23 is not supported at the moment.
Commands
Run the following commands to build the Android version:
1. Install dependencies
Assuming you are on the root of the repo, start from here:
cd ./client
rm -r ./node_modules
rm -r ./android
pnpm install
And add EXPO_PUBLIC_API_URL=<api base url> to .env file.
2. Generate android build directory
npx expo prebuild --clean
3. Use upload keystore file
3.1. (optional) Generate keystore key
Skip this step if you already have the upload keystore file, which should be shared by the devops engineer.
In case you want to generate a new one, run these commands:
sudo keytool -genkey -v -keystore upload-key.keystore -alias upload-key -keyalg RSA -keysize 2048 -validity 10000
3.2. (optional) Upload to Google Play
Skip this step if you already have the upload keystore file, which should be shared by the devops engineer.
keytool -export -rfc -keystore upload-key.keystore -alias upload-key -file upload_certificate.pem
3.3. Move file to ./android/app
mv upload-key.keystore ./android/app
4. Modify gradle properties
Add the following to ./client/android/gradle.properties:
**NOTE: make sure to replace <password> with the password shared by the devops engineers, or the one you created above.
MYAPP_UPLOAD_STORE_FILE=upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=upload-key
MYAPP_UPLOAD_STORE_PASSWORD=<password>
MYAPP_UPLOAD_KEY_PASSWORD=<password>
Then modify ./client/android/app/build.gradle by adding the lines marked by '+':
android {
signingConfigs {
// ...
+ release {
+ if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
+ storeFile file(MYAPP_UPLOAD_STORE_FILE)
+ storePassword MYAPP_UPLOAD_STORE_PASSWORD
+ keyAlias MYAPP_UPLOAD_KEY_ALIAS
+ keyPassword MYAPP_UPLOAD_KEY_PASSWORD
+ }
+ }
}
buildTypes {
// ...
release {
signingConfig signingConfigs.debug
+ signingConfig signingConfigs.release
minifyEnabled false
// ...
}
}
}
5. Build app
cd ./android
./gradlew clean
./gradlew app:bundleRelease