Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

Install script: find the JDK and Android SDK on Linux

Aleksander Sandnesddacaf3aa57e
diff --git a/README.md b/README.md
index d49efe57e..2c6e30f16 100644
--- a/README.md
+++ b/README.md
@@ -165,7 +165,8 @@ The install scripts ask the TV which launcher owns Home and only disable one the
A small native Android TV app (`com.gathin.tvhome`, about 250 KB installed) in plain Java with
AndroidX RecyclerView and nothing heavier. Built for sets with 1 GB of RAM: no blur, no video, no
network, no background services. It needs JDK 17 and Android SDK platform 34 to build; on macOS,
-`brew install openjdk@17 android-commandlinetools` and `sdkmanager "platforms;android-34" "build-tools;34.0.0"`.
+`brew install openjdk@17 android-commandlinetools` and `sdkmanager "platforms;android-34" "build-tools;34.0.0"`. On Linux
+the install script finds `~/Android/Sdk` and the `java` on your PATH.
- **Configure** in [`config.xml`](launcher/app/src/main/res/values/config.xml): dock order, hidden apps, the Live TV package, columns (tiles shrink from 5 up), rows under the dock, an optional VPN app for the network pill.
- **Themes** set the same keys plus a background colour and a wallpaper from a `config.json` pushed to the TV, no rebuild. Three ship in [`themes/`](themes/), documented there.
diff --git a/launcher/build-and-install.sh b/launcher/build-and-install.sh
index 0d71a6e5c..cd3bc936c 100755
--- a/launcher/build-and-install.sh
+++ b/launcher/build-and-install.sh
@@ -3,13 +3,17 @@
set -euo pipefail
cd "$(dirname "$0")"
: "${TV_HOST:?set TV_HOST to the TV IP address, e.g. TV_HOST=192.168.1.50 $0}"
-export JAVA_HOME="${JAVA_HOME:-$(/usr/libexec/java_home -v 17 2>/dev/null || echo /opt/homebrew/opt/openjdk@17)}"
-export ANDROID_HOME="${ANDROID_HOME:-$([ -d ~/Library/Android/sdk ] && echo ~/Library/Android/sdk || echo /opt/homebrew/share/android-commandlinetools)}"
+# macOS: java_home or Homebrew; Linux: the java on PATH.
+export JAVA_HOME="${JAVA_HOME:-$(/usr/libexec/java_home -v 17 2>/dev/null || { [ -d /opt/homebrew/opt/openjdk@17 ] && echo /opt/homebrew/opt/openjdk@17; } || java -XshowSettings:properties -version 2>&1 | awk '/java.home/ {print $3}')}"
+# Android Studio's default SDK location on macOS, then on Linux, then Homebrew's command-line tools.
+export ANDROID_HOME="${ANDROID_HOME:-$(for d in ~/Library/Android/sdk ~/Android/Sdk; do [ -d "$d" ] && echo "$d" && break; done)}"
+export ANDROID_HOME="${ANDROID_HOME:-/opt/homebrew/share/android-commandlinetools}"
export PATH="$JAVA_HOME/bin:$PATH"
[ -f local.properties ] || echo "sdk.dir=$ANDROID_HOME" > local.properties
./gradlew assembleRelease -q --console=plain
-PY=../tools/venv/bin/python
-[ -x "$PY" ] || PY=../tools/venv/Scripts/python.exe
+TOOLS="$(cd ../tools && pwd)" # absolute, so the venv's Python doesn't warn about "../" in its prefix
+PY=$TOOLS/venv/bin/python
+[ -x "$PY" ] || PY=$TOOLS/venv/Scripts/python.exe
export MSYS_NO_PATHCONV=1
# Which app owns Home differs by build (com.google.android.tvlauncher on Android TV,
# com.google.android.apps.tv.launcherx on newer Google TV), so ask the TV instead of guessing.