Skip to content

Commit 73d8e10

Browse files
committed
Add CLI build instructions (#2515)
1 parent c1fedcb commit 73d8e10

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

docs/EN/SettingUpAaps/BuildingAaps.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,10 @@ You can build the app with your computer using Android Studio.
2424

2525
**[Follow these instructions.](./ComputerBuild.md)**
2626

27+
----
28+
29+
### Build using the command-line
30+
31+
This option is intended for those who prefer to build AAPS in local command-line, without installing Android Studio.
32+
33+
**[Follow these instructions.](./CLIBuild.md)**

docs/EN/SettingUpAaps/CLIBuild.md

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

docs/EN/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Setting up the reporting server <./SettingUpAaps/SettingUpTheReportingServer.md>
9494
Building AAPS <./SettingUpAaps/BuildingAaps.md>
9595
- Browser Build <./SettingUpAaps/BrowserBuild.md>
9696
- Computer Build <./SettingUpAaps/ComputerBuild.md>
97+
- CLI Build <./SettingUpAaps/CLIBuild.md>
9798
Transferring and Installing AAPS <./SettingUpAaps/TransferringAndInstallingAaps.md>
9899
Setup Wizard <./SettingUpAaps/SetupWizard.md>
99100
Your AAPS Profile <./SettingUpAaps/YourAapsProfile.md>

0 commit comments

Comments
 (0)