no Android NDK found in $ANDROID_HOME/ndk-bundle nor in $ANDROID_NDK_HOME in Windows 10

3.3k Views Asked by At

I'm following the official guide to install gomobile. I have Android Studio installed and via the Android Studio SDK manage installed NDK (side by side) and all the SDK packages. Android Studio has no problem compiling and deploying my normal Android apps to me device.

I ran successfully (by which I mean without any errors):

go env -w GO111MODULE=auto

gomobile init

go get -d golang.org/x/mobile/example/basic

Then I ran:

gomobile build -target=android golang.org/x/mobile/example/basic

And got the error:

gomobile: no Android NDK found in $ANDROID_HOME/ndk-bundle nor in $ANDROID_NDK_HOME

When I run as suggested in the answer to another older thread:

gomobile init -ndk C:\Users\Christian\AppData\Local\Android\Sdk\ndk-bundle

I get:

flag provided but not defined: -ndk
usage: gomobile init [-openal dir]

What do I need to do to fix this?

2

There are 2 best solutions below

2
On

Solution for linux/mac users

I had the same problem on Linux, and I solved it by making the environment variable like this:

export ANDROID_HOME=$HOME/Android/Sdk

in this path I have the ndk-bundle folder which can also be downloaded from here

after that i could simply run

gomobile bind -x -v .

in my project directory and I get the .aar file that I want.

0
On

I had this problem on Windows 10 as well. I fixed it by adding a new environment variable.

  1. Press [Windows Key + S] to open the search menu.
  2. Search for "Edit the System Environment Variables"
  3. Click on "New" There will be two "New" buttons, you may use the upper one to make it local to your user
  4. For Variable name enter: ANDROID_NDK_HOME
  5. For Variable value enter: C:\Users\John\AppData\Local\Android\Sdk\ndk (or wherever you installed your NDK, I installed it with Android Studio and it went here by default)

I hesitated to provide this as an answer because I still can't build my Fyne app. Now I get no compiler for arm64 was found in the NDK (tried ). Make sure your NDK version is >= r19c. Use sdkmanager --update to update it

I answered anyway because it does solve the error in question and this next error may be specific to me.