Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active March 27, 2026 03:16
Show Gist options
  • Select an option

  • Save sogaiu/c28e482a7091ce02740af9d03fa6ab9b to your computer and use it in GitHub Desktop.

Select an option

Save sogaiu/c28e482a7091ce02740af9d03fa6ab9b to your computer and use it in GitHub Desktop.
trying out clj-android sample

steps

jdk, android sdk, etc.

  • 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 source on 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 named cmdline-tools. rename it to latest and place it in a directory named cmdline-tools (probably need to create it) under $ANDROID_HOME, i.e. $HOME/android/cmdline-tools/latest is where the content within the uncompressed result directory (originall cmdline-tools) shoudl end up. yeah, complicated, seems like this is google's doing.

  • try sdkmanager --list to 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"

clj-android sample

  • 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 adb or 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-c to 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!)

references

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment