Skip to content

Commit 936940e

Browse files
Move the dependency installer script and remove build_android.sh script and update .gitignore to include shell files in the root dir.
1 parent 3d204bb commit 936940e

File tree

5 files changed

+59
-84
lines changed

5 files changed

+59
-84
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Ignore all shell scripts in the root directory
2+
/*.sh
3+
14
.vs/
25
.vscode/
36
.idea/

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ To build for Android, you need a few SDKs! [Android Studio](https://developer.an
4949
### If building on Ubuntu 24.04 onwards (CLI): Quick setup
5050
If you prefer the command line on Linux, this is a minimal setup that matches the versions this template targets.
5151

52-
### Auto-Setup:
52+
### (Optional) Auto-Setup:
5353

54-
Just run `bash install_android_deps.sh`. Everything will be installed for you.
54+
Just run `bash install_android_deps.sh` located in android/scripts/. Everything will be installed for you!
5555

5656
### Manual Setup:
5757
<details>
@@ -141,10 +141,6 @@ Ninja's [site is here](https://ninja-build.org/), but you can install it quite e
141141

142142
## Android Build
143143

144-
### for automated Android Build on Linux just run `build_android.sh`
145-
146-
147-
148144
```shell
149145
# From the project root directory
150146

@@ -163,7 +159,7 @@ cmake -B build-android ^
163159
# Same, but as a single line. Nicer if not using a .bat
164160
cmake -B build-android -G Ninja -DCMAKE_ANDROID_NDK=%ANDROID_NDK_HOME% -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=32 -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a
165161

166-
#Or for Linux:
162+
# Or for Linux (notice the $ instead of the %):
167163
cmake -B build-android -G Ninja -DCMAKE_ANDROID_NDK=$ANDROID_NDK_HOME -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=32 -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a
168164

169165

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# install_android-deps.sh: Install all dependencies for Android build on Linux
3+
4+
set -e
5+
6+
# Prevent running the whole script with sudo/root.
7+
# We still use sudo for apt installs below, but the SDK should be under the user home, not /root.
8+
if [ "$(id -u)" -eq 0 ]; then
9+
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
10+
echo "This script should not be run with sudo. Re-running as $SUDO_USER..."
11+
exec sudo -u "$SUDO_USER" -H bash "$0" "$@"
12+
else
13+
echo "Please run this script without sudo (it will use sudo only where needed)." >&2
14+
exit 1
15+
fi
16+
fi
17+
18+
sudo apt update
19+
sudo apt install -y cmake libx11-dev libxfixes-dev libegl-dev libgbm-dev libfontconfig-dev unzip curl zip ninja-build openjdk-8-jdk adb google-android-cmdline-tools-13.0-installer
20+
21+
export ANDROID_HOME="$HOME/Android/Sdk"
22+
export ANDROID_SDK_ROOT="$ANDROID_HOME"
23+
export PATH="$ANDROID_HOME/platform-tools:$PATH"
24+
25+
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/25.2.9519653"
26+
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
27+
export PATH="$JAVA_HOME/bin:$PATH"
28+
29+
30+
sdkmanager --sdk_root=$ANDROID_HOME \
31+
"platform-tools" \
32+
"platforms;android-32" \
33+
"build-tools;32.0.0" \
34+
"ndk;25.2.9519653"
35+
36+
37+
echo
38+
read -p "Add Android environment variables to your ~/.bashrc for future sessions? If not, you will need to set them manually. [y/N] " add_envs
39+
if [[ "$add_envs" =~ ^[Yy]$ ]]; then
40+
{
41+
echo ''
42+
echo '# Android SDK/NDK environment variables (added by install_android_deps.sh)'
43+
echo 'export ANDROID_HOME="$HOME/Android/Sdk"'
44+
echo 'export ANDROID_SDK_ROOT="$ANDROID_HOME"'
45+
echo 'export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/25.2.9519653"'
46+
echo 'export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"'
47+
echo 'export PATH="$ANDROID_HOME/platform-tools:$JAVA_HOME/bin:$PATH"'
48+
} >> "$HOME/.bashrc"
49+
echo "Variables added to ~/.bashrc. Please restart your terminal or run: source ~/.bashrc"
50+
else
51+
echo "Skipped adding environment variables to ~/.bashrc."
52+
fi
53+

build_android.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.

install_android_deps.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)