tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.9k stars 2.6k forks source link

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

Open TickJar opened 1 day ago

TickJar commented 1 day ago

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 commented 1 day ago

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)
FabianLars commented 21 hours ago

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 ?

TickJar commented 15 hours ago

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! 🌻 🐕 🎉