|
| 1 | +# Build instructions for the command-line |
| 2 | + |
| 3 | +```{admonition} For users familiar with the command-line and git |
| 4 | +:class: information |
| 5 | +
|
| 6 | +The simplest option to build AAPS is the [Browser build](./BrowserBuild.md) alternative. |
| 7 | +``` |
| 8 | + |
| 9 | +Tested with Fedora and Debian Linux, other systems should work with minimal adjustments. |
| 10 | + |
| 11 | +## Požadavky |
| 12 | + |
| 13 | +Consult the minimum required Java version from [this table](#Building-APK-recommended-specification-of-computer-for-building-apk-file). Install the appropriate OpenJDK package using the system package manager. For example in Debian, the packages are named like `openjdk-21-jdk`. It should include `javac` and `keytool` binaries. |
| 14 | + |
| 15 | +Download the *Android Command line tools* package from the [Android Studio page](https://developer.android.com/studio#command-line-tools-only). Android Studio itself is not required. More information about installing this package is found in [sdkmanager docs](https://developer.android.com/tools/sdkmanager). After the package is installed, you should manually set two [environment variables](https://developer.android.com/tools/variables): `ANDROID_HOME` and `PATH`. Finally, run `sdkmanager --licenses` to finish the installation. |
| 16 | + |
| 17 | +## Building AAPS with Gradle wrapper |
| 18 | + |
| 19 | +### 1. Generate a Java keystore file for signing AAPS |
| 20 | + |
| 21 | +If you already have a keystore file for signing AAPS, reuse that. |
| 22 | + |
| 23 | +```sh |
| 24 | +keytool -genkeypair -v \ |
| 25 | + -keystore aaps-keystore.jks \ |
| 26 | + -alias aaps-key \ |
| 27 | + -keyalg RSA \ |
| 28 | + -keysize 4096 \ |
| 29 | + -validity 20000 |
| 30 | +``` |
| 31 | + |
| 32 | +You will need the keystore file and passphrase every time you update AAPS. |
| 33 | + |
| 34 | +### 2. Compile the AAPS APK file |
| 35 | + |
| 36 | +Clone the [git repo](https://github.com/nightscout/AndroidAPS) if not already cloned. AAPS uses master branch for the latest stable version, ensure you are on the branch/tag you want to build. |
| 37 | + |
| 38 | +Run `./gradlew :app:assembleFullRelease` in the repo. It automatically downloads Gradle, dependencies, and then compiles the code. When the build succeeds, you should have an unsigned APK at `app/build/outputs/apk/full/release/app-full-release-unsigned.apk`. It should have also installed an `apksigner` binary to `$ANDROID_HOME`. Update your `PATH` again. |
| 39 | + |
| 40 | +### 3. Create a signed APK file from the unsigned one |
| 41 | + |
| 42 | +<!-- Suggest building outside the git repo, to minimize risk of accidental APK commits --> |
| 43 | + |
| 44 | +Change to your home directory and create a signed APK file: |
| 45 | + |
| 46 | +```sh |
| 47 | +apksigner sign \ |
| 48 | + --ks path/to/aaps-keystore.jks \ |
| 49 | + --ks-key-alias aaps-key \ |
| 50 | + --out app-full-release-signed.apk \ |
| 51 | + ./AndroidAPS/app/build/outputs/apk/full/release/app-full-release-unsigned.apk |
| 52 | +``` |
| 53 | + |
| 54 | +Now you have `app-full-release-signed.apk` ready for installation or upgrade. |
0 commit comments