-
make sure jdk 21+ (<26) is installed
$ java --version openjdk 21.0.10 2026-01-20 OpenJDK Runtime Environment (build 21.0.10+7-Ubuntu-124.04) OpenJDK 64-Bit Server VM (build 21.0.10+7-Ubuntu-124.04, mixed mode, sharing) -
download cmdline-tools from https://developer.android.com/studio#command-tools (at time of writing, checksum was mentioned as sha-256, but in fact was md5). file's name likely something like:
commandlinetools-linux-14742923_latest.zip.$ sha256sum commandlinetools-linux-14742923_latest.zip 04453066b540409d975c676d781da1477479dde3761310f1a7eb92a1dfb15af7 commandlinetools-linux-14742923_latest.zip $ shasum commandlinetools-linux-14742923_latest.zip 48833c34b761c10cb20bcd16582129395d121b27 commandlinetools-linux-14742923_latest.zip -
set some environment variables (hint: place in file and use
sourceon it when needed)export ANDROID_HOME=$HOME/android export ANDROID_SDK_ROOT=$ANDROID_HOME export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH -
mkdir $ANDROID_HOME -
unzip
commandlinetools-linux-14742923_latest.zip- this should produce a directory namedcmdline-tools. rename it tolatestand place it in a directory namedcmdline-tools(probably need to create it) under$ANDROID_HOME, i.e.$HOME/android/cmdline-tools/latestis where the content within the uncompressed result directory (originallcmdline-tools) shoudl end up. yeah, complicated, seems like this is google's doing. -
try
sdkmanager --listto make sure things work. if not, confirm instructions above were followed or find other fix. -
install build-tools 35.0.1:
sdkmanager "build-tools;35.0.1" -
install platform 35:
sdkmanager "platforms;android-35"
-
clone sample...but use a different name:
cd ~/src && git clone https://github.com/clj-android/sample clj-android-sample -
cd clj-android-sample -
build debug apk:
./gradlew assembleDebug -
install apk:
./gradlew installDebug -
launch the apk (can be via
adbor directly on the device) -
connect android device with dev mode enabled and usb debugging set (or make appropriately setup emulator available)
-
make it possible for an nrepl connection from host to android device:
adb forward tcp:7888 tcp:7888 -
connect via nrepl (e.g. using cider's
cider-connect-clj/C-c M-cto localhost 7888) -
try the following code -- success should result in main activity window looking different:
(require '[com.example.clojuredroid.main-activity :as ui]) (reset! ui/ui-tree* [:linear-layout {:orientation :vertical :padding [32 32 32 32]} [:text-view {:text "Modified from REPL!" :text-size [24 :sp]}]]) (ui/reload-ui!)