tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] running `tauri android init` returns `NDK_HOME` environment variable isn't set, but the NDK is installed

Open TickJar opened this issue 1 year ago • 7 comments

Describe the bug

After following the prerequisites doc to the letter, installing Android Studio and downloading all the latest SDKs and NDKs, I'm still getting this error when running tauri android init:

action request:  to initialize Android environment; Android support won't be usable until you
fix the issue below and re-run `tauri android init`!
    Have you installed the NDK? The `NDK_HOME` environment variable isn't set, and is
    required: environment variable not found

What can be causing this to KEEP happening? This results in Android Studio reporting Error running 'app' Default Activity not found after running tauri android dev

Reproduction

No response

Expected behavior

Tauri should be able to detect the installed NDK

Full tauri info output

action request:  to initialize Android environment; Android support won't be usable until you
fix the issue below and re-run `tauri android init`!
    Have you installed the NDK? The `NDK_HOME` environment variable isn't set, and is
    required: environment variable not found

Stack trace

No response

Additional context

No response

TickJar avatar Dec 02 '24 00:12 TickJar

My mistake, here is the tauri info output:

[✔] Environment
    - OS: Mac OS 15.1.1 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.13.1
    - pnpm: 8.15.8
    - npm: 10.5.2

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.2
    - tao 🦀: 0.30.8
    - tauri-cli 🦀: 2.1.0
    - @tauri-apps/api : 2.1.1
    - @tauri-apps/cli : 2.0.0-rc.18 (outdated, latest: 2.1.0)

[-] Plugins

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite

[-] iOS
    - Developer Teams: Jared Griffin (ID: 54T34FM7VV)

TickJar avatar Dec 02 '24 00:12 TickJar

So i assume by "following the prereqs" included this android part right? https://tauri.app/start/prerequisites/#android If so, can you share the output of ls $ANDROID_HOME/ndk ?

FabianLars avatar Dec 02 '24 09:12 FabianLars

So i assume by "following the prereqs" included this android part right? https://tauri.app/start/prerequisites/#android If so, can you share the output of ls $ANDROID_HOME/ndk ?

So I have run into this a few times. It seems like following the guide you mentioned above points NDK_HOME to a folder that doesn't exist... but it does...

Screenshot 2024-12-02 at 9 58 19 AM


tickjar@Jareds-MacBook-Pro tauri-ta % printenv                                       
MallocNanoZone=0
USER=tickjar
SECURITYSESSIONID=186c3
COMMAND_MODE=unix2003
__CFBundleIdentifier=com.microsoft.VSCode
PATH=/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/bin:/opt/homebrew/opt/openjdk@17/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/bin:/opt/homebrew/opt/openjdk@17/bin:/Users/tickjar/Library/pnpm:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Users/tickjar/.cargo/bin:/Users/tickjar/Library/Android/sdk/platform-tools:/Users/tickjar/Library/Android/sdk/tools:/Users/tickjar/Library/Android/sdk/tools/bin:/Users/tickjar/Library/Android/sdk/emulator:/Users/tickjar/Library/Android/sdk/platform-tools:/Users/tickjar/Library/Android/sdk/tools:/Users/tickjar/Library/Android/sdk/tools/bin:/Users/tickjar/Library/Android/sdk/emulator
HOME=/Users/tickjar
SHELL=/bin/zsh
LaunchInstanceID=C5BA7CBD-BBE6-4202-AC6F-48053B18ACC9
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
XPC_SERVICE_NAME=0
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.jQ7bz0xF7D/Listeners
XPC_FLAGS=0x0
LOGNAME=tickjar
TMPDIR=/var/folders/70/j37gm_b507nfl616t1t_cx1h0000gn/T/
ORIGINAL_XDG_CURRENT_DESKTOP=undefined
SHLVL=1
PWD=/Users/tickjar/Sites/tauri-ta
OLDPWD=/Users/tickjar/Sites/tauri-ta
HOMEBREW_PREFIX=/opt/homebrew
HOMEBREW_CELLAR=/opt/homebrew/Cellar
HOMEBREW_REPOSITORY=/opt/homebrew
INFOPATH=/opt/homebrew/share/info:/opt/homebrew/share/info:
PNPM_HOME=/Users/tickjar/Library/pnpm
ANDROID_HOME=/Users/tickjar/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home
TERM_PROGRAM=vscode
TERM_PROGRAM_VERSION=1.95.3
LANG=en_US.UTF-8
COLORTERM=truecolor
GIT_ASKPASS=/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass.sh
VSCODE_GIT_ASKPASS_NODE=/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin)
VSCODE_GIT_ASKPASS_EXTRA_ARGS=
VSCODE_GIT_ASKPASS_MAIN=/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass-main.js
VSCODE_GIT_IPC_HANDLE=/var/folders/70/j37gm_b507nfl616t1t_cx1h0000gn/T/vscode-git-aa5743bfa6.sock
VSCODE_INJECTION=1
ZDOTDIR=/Users/tickjar
USER_ZDOTDIR=/Users/tickjar
TERM=xterm-256color
**NDK_HOME=/Users/tickjar/Library/Android/sdk/ndk/27.0.12077973**
LANG=en_US.UTF-8
_=/usr/bin/printenv


tickjar@Jareds-MacBook-Pro tauri-ta % tauri android init
action request:  to initialize Android environment; Android support won't be usable until you fix the issue below and re-run `tauri android init`!
    Have you installed the NDK? **The `NDK_HOME` environment variable is set, but doesn't point to an existing directory**.
victory: Project generated successfully!
    Make cool apps! 🌻 🐕 🎉

TickJar avatar Dec 02 '24 15:12 TickJar

export NDK_HOME="$ANDROID_HOME/ndk/$(ls -1 $ANDROID_HOME/ndk)"

carly1987 avatar Dec 03 '24 09:12 carly1987

export NDK_HOME="$ANDROID_HOME/ndk/$(ls -1 $ANDROID_HOME/ndk)"

So this is leading to some enlightenment on my end. I'm not sure if this is expected behavior, but entering these commands into my terminal doesn't seem to stick when I set these variables in the project folder via the terminal in my IDE (vsCode).

This did result in tauri android init running successfully. However, now tauri android dev results in a lengthy and cryptic error:

       Info symlinking lib "/Users/tickjar/Sites/tauri-ta/src-tauri/target/aarch64-linux-android/debug/libapp_lib.so" in jniLibs dir "/Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a"
    Info "/Users/tickjar/Sites/tauri-ta/src-tauri/target/aarch64-linux-android/debug/libapp_lib.so" requires shared lib "libandroid.so"
    Info "/Users/tickjar/Sites/tauri-ta/src-tauri/target/aarch64-linux-android/debug/libapp_lib.so" requires shared lib "libdl.so"
    Info "/Users/tickjar/Sites/tauri-ta/src-tauri/target/aarch64-linux-android/debug/libapp_lib.so" requires shared lib "liblog.so"
    Info "/Users/tickjar/Sites/tauri-ta/src-tauri/target/aarch64-linux-android/debug/libapp_lib.so" requires shared lib "libm.so"
    Info "/Users/tickjar/Sites/tauri-ta/src-tauri/target/aarch64-linux-android/debug/libapp_lib.so" requires shared lib "libc.so"
    Info symlink at "/Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a/libapp_lib.so" points to "/Users/tickjar/Sites/tauri-ta/src-tauri/target/aarch64-linux-android/debug/libapp_lib.so"
'compileJava' task (current target is 21) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/builder-model/8.3.2/58cdfab79e8641b54ac79b448f11158a2dde47f5/builder-model-8.3.2.jar!/META-INF/builder-model.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
e: /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/builder/8.3.2/ac4f58c45b74cf8b2b81bfdae3d61109f82697e4/builder-8.3.2.jar!/META-INF/builder.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
e: /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/builder/8.3.2/ac4f58c45b74cf8b2b81bfdae3d61109f82697e4/builder-8.3.2.jar!/META-INF/profile.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
e: /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-api/8.3.2/b1ad77b6f83e2020f566ad1bd76991ef8b29c98e/gradle-api-8.3.2.jar!/META-INF/gradle-api.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
e: /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle/8.3.2/92b2d743ea3e3cdba8b939a94465b2ba654e7b11/gradle-8.3.2.jar!/META-INF/common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
e: /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle/8.3.2/92b2d743ea3e3cdba8b939a94465b2ba654e7b11/gradle-8.3.2.jar!/META-INF/gradle-core.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
e: /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle/8.3.2/92b2d743ea3e3cdba8b939a94465b2ba654e7b11/gradle-8.3.2.jar!/META-INF/kotlin-multiplatform-models.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
e: /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle/8.3.2/92b2d743ea3e3cdba8b939a94465b2ba654e7b11/gradle-8.3.2.jar!/META-INF/profgen.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
e: /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle/8.3.2/92b2d743ea3e3cdba8b939a94465b2ba654e7b11/gradle-8.3.2.jar!/META-INF/shrinker.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
e: /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/manifest-merger/31.3.2/2f84df3997cd44cadeaf1fb68fdd9a154dec63e3/manifest-merger-31.3.2.jar!/META-INF/manifest-merger.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
e: /Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/buildSrc/src/main/java/com/ta/app/kotlin/RustPlugin.kt: (1, 34): Class 'com.android.build.api.dsl.ApplicationExtension' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
The class is loaded from /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-api/8.3.2/b1ad77b6f83e2020f566ad1bd76991ef8b29c98e/gradle-api-8.3.2.jar!/com/android/build/api/dsl/ApplicationExtension.class
e: /Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/buildSrc/src/main/java/com/ta/app/kotlin/RustPlugin.kt: (28, 30): Class 'com.android.build.api.dsl.ApplicationExtension' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
The class is loaded from /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-api/8.3.2/b1ad77b6f83e2020f566ad1bd76991ef8b29c98e/gradle-api-8.3.2.jar!/com/android/build/api/dsl/ApplicationExtension.class
e: /Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/buildSrc/src/main/java/com/ta/app/kotlin/RustPlugin.kt: (32, 17): Class 'com.android.build.api.dsl.ApplicationProductFlavor' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
The class is loaded from /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-api/8.3.2/b1ad77b6f83e2020f566ad1bd76991ef8b29c98e/gradle-api-8.3.2.jar!/com/android/build/api/dsl/ApplicationProductFlavor.class
e: /Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/buildSrc/src/main/java/com/ta/app/kotlin/RustPlugin.kt: (39, 21): Class 'com.android.build.api.dsl.ApplicationProductFlavor' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.5.1.
The class is loaded from /Users/tickjar/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-api/8.3.2/b1ad77b6f83e2020f566ad1bd76991ef8b29c98e/gradle-api-8.3.2.jar!/com/android/build/api/dsl/ApplicationProductFlavor.class
e: /Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/buildSrc/src/main/java/com/ta/app/kotlin/RustPlugin.kt: (51, 50): Unresolved reference: replaceFirstChar
e: /Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/buildSrc/src/main/java/com/ta/app/kotlin/RustPlugin.kt: (51, 69): Unresolved reference: it
e: /Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/buildSrc/src/main/java/com/ta/app/kotlin/RustPlugin.kt: (65, 60): Unresolved reference: replaceFirstChar
e: /Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/buildSrc/src/main/java/com/ta/app/kotlin/RustPlugin.kt: (65, 79): Unresolved reference: it

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildSrc:compileKotlin'.
> Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Failed to assemble APK: command ["/Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/gradlew", "--project-dir", "/Users/tickjar/Sites/tauri-ta/src-tauri/gen/android"] exited with code 1: command ["/Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/gradlew", "--project-dir", "/Users/tickjar/Sites/tauri-ta/src-tauri/gen/android"] exited with code 1
    Error Failed to assemble APK: command ["/Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/gradlew", "--project-dir", "/Users/tickjar/Sites/tauri-ta/src-tauri/gen/android"] exited with code 1: command ["/Users/tickjar/Sites/tauri-ta/src-tauri/gen/android/gradlew", "--project-dir", "/Users/tickjar/Sites/tauri-ta/src-tauri/gen/android"] exited with code 1
tickjar@Jareds-MacBook-Pro tauri-ta % E1203 12:02:32.892239 7417000 FrameBuffer.cpp:3619] Failed to find ColorBuffer:0
INFO    | Wait for emulator (pid 74548) 20 seconds to shutdown gracefully before kill;you can set environment variable ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL(in seconds) to change the default value (20 seconds)

INFO    | Saving with gfxstream=1
INFO    | OpenGL Vendor=[Google (Apple)]
INFO    | OpenGL Renderer=[Android Emulator OpenGL ES Translator (Apple M3 Pro)]
INFO    | OpenGL Version=[OpenGL ES 3.0 (4.1 Metal - 89.3)]
E1203 12:02:36.388372 18bb840 DisplaySurfaceGl.cpp:125] Failed to restore previous context: 12297

TickJar avatar Dec 03 '24 18:12 TickJar

Also, after running tauri android dev, running tauri android init results in the same error appearing:

action request:  to initialize Android environment; Android support won't be
usable until you fix the issue below and re-run `tauri android init`!
    Have you installed the NDK? The `NDK_HOME` environment variable is set,
    but doesn't point to an existing directory.

TickJar avatar Dec 03 '24 18:12 TickJar

I'm not sure if this is expected behavior, but entering these commands into my terminal doesn't seem to stick when I set these variables in the project folder via the terminal in my IDE (vsCode).

It is, if you want them to be permanent you have to add that to .zshrc or .zprofile. idk why the docs are missing that

FabianLars avatar Dec 03 '24 18:12 FabianLars

export NDK_HOME="$ANDROID_HOME/ndk/$(ls -1 $ANDROID_HOME/ndk)"

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.1 LTS
Release:        24.04
Codename:       noble
ls -1 $ANDROID_HOME/ndk
25.0.8775105
26.1.10909125
"dependencies": {
    "@tauri-apps/api": "^2.0.0-alpha.5",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@tauri-apps/cli": "^2.0.0-alpha.10",
    "@types/react": "^18.2.15",
    "@types/react-dom": "^18.2.7",
    "@vitejs/plugin-react": "^4.0.3",
    "internal-ip": "^8.0.0",
    "typescript": "^5.0.2",
    "vite": "^4.4.4"
  },
yarn tauri android init
yarn run v1.22.22
$ tauri android init
action request:  to initialize Android environment; Android support won't be usable
until you fix the issue below and re-run `tauri android init`!
    Have you installed the NDK? The `NDK_HOME` environment variable is set, but doesn't point to an
    existing directory.
victory: Project generated successfully!
    Make cool apps! 🌻 🐕 🎉
Done in 1.11s.

but it looks like latest example same

pnpm create tauri-app
cd tauri-app
pnpm install
pnpm tauri dev
 pnpm tauri android dev

> [email protected] tauri /home/burak/Desktop/tauri/tauri-app
> tauri "android" "dev"

Have you installed the NDK? The `NDK_HOME` environment variable is set, but doesn't point to an exis
ting directory.
    Error Have you installed the NDK? The `NDK_HOME` environment variable is set, but doesn't point
to an existing directory.
 ELIFECYCLE  Command failed with exit code 1.
 ```

burakakca avatar Dec 31 '24 09:12 burakakca

export NDK_HOME="$ANDROID_HOME/ndk/$(ls -1 $ANDROID_HOME/ndk)"

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.1 LTS
Release:        24.04
Codename:       noble
ls -1 $ANDROID_HOME/ndk
25.0.8775105
26.1.10909125
"dependencies": {
   "@tauri-apps/api": "^2.0.0-alpha.5",
   "react": "^18.2.0",
   "react-dom": "^18.2.0"
 },
 "devDependencies": {
   "@tauri-apps/cli": "^2.0.0-alpha.10",
   "@types/react": "^18.2.15",
   "@types/react-dom": "^18.2.7",
   "@vitejs/plugin-react": "^4.0.3",
   "internal-ip": "^8.0.0",
   "typescript": "^5.0.2",
   "vite": "^4.4.4"
 },
yarn tauri android init
yarn run v1.22.22
$ tauri android init
action request:  to initialize Android environment; Android support won't be usable
until you fix the issue below and re-run `tauri android init`!
   Have you installed the NDK? The `NDK_HOME` environment variable is set, but doesn't point to an
   existing directory.
victory: Project generated successfully!
   Make cool apps! 🌻 🐕 🎉
Done in 1.11s.

but it looks like latest example same

pnpm create tauri-app
cd tauri-app
pnpm install
pnpm tauri dev
 pnpm tauri android dev

> [email protected] tauri /home/burak/Desktop/tauri/tauri-app
> tauri "android" "dev"

Have you installed the NDK? The `NDK_HOME` environment variable is set, but doesn't point to an exis
ting directory.
   Error Have you installed the NDK? The `NDK_HOME` environment variable is set, but doesn't point
to an existing directory.
 ELIFECYCLE  Command failed with exit code 1.
 ```

same issue

aafnnp avatar Jan 07 '25 06:01 aafnnp

When I use it directly in Terminal it works, but otherwise it does not.

burakakca avatar Jan 07 '25 15:01 burakakca

I made it work by adding environment variables:

export ANDROID_HOME="$HOME/Android/Sdk" export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/28.0.12916984" export NDK_HOME="$ANDROID_HOME/ndk/28.0.12916984"

It seems that the method given by tauri prerequisites: export NDK_HOME="$ANDROID_HOME/ndk/$(ls -1 $ANDROID_HOME/ndk)" not works, especially when you have more than one ndk verisons.

Rcmane avatar Jan 16 '25 16:01 Rcmane

I found a workaround! I named the environment variable "NDKROOT" instead of "NDK_HOME". Ran npm run tauri android init and npm run tauri android build and it built successfully. Was able to run my app on my phone via wireless debugging too! Can someone confirm?

akcrittenden avatar Feb 07 '25 01:02 akcrittenden

@Rcmane method worked for me as well. I replaced the $(ls -1 $ANDROID_HOME/ndk) with the literal folder name, in my case 29.0.13113456. I think the error is that the $(ls -1 $ANDROID_HOME/ndk) resolves to /Users/ph1/Library/Android/sdk/ndk/\033[34m29.0.13113456\033[39;49m\033[0m, which includes the \033[34m and \033[39;49m\033[0m strings, which set the text color in the terminal.

This is due to my alias of ls to ls --color=auto.

I could fix the code by: A: setting the ndk folder name manually to 29.0.13113456 NDK_HOME="$ANDROID_HOME/ndk/"

B: making sure that ls does not use colors by adding --color=never: NDK_HOME="$ANDROID_HOME/ndk/$(ls --color=never -1 $ANDROID_HOME/ndk)"

F-Kirchhoff avatar Mar 21 '25 10:03 F-Kirchhoff

This was my issue - I think the docs should be updated with the --color=never flag.

AravindPrabhs avatar Apr 06 '25 12:04 AravindPrabhs

In my case, the issue is caused by the fact that I have two versions of ndk, and after running the command in the docs, my 'NDK_HOME' environment variable becomes C:\Users\20030813\AppData\Local\Android\Sdk\ndk\26.1.10909125 29.0.13113456 It's not a correct path, just need to pick a version, I changed it
C:\Users\20030813\AppData\Local\Android\Sdk\ndk\29.0.13113456 Anything will be right

JinJieBeWater avatar Apr 13 '25 14:04 JinJieBeWater

The problem is not really the color, it is the fact that ls -l will resolve to multiple lines if the user has more than one NDK installed. The guide should use ls $ANDROID_HOME/ndk | tail -n 1 instead.

lhsantos avatar Jul 09 '25 01:07 lhsantos