4

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?

Christian
  • 25,249
  • 40
  • 134
  • 225

1 Answers1

1

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.

mama
  • 2,046
  • 1
  • 7
  • 24
  • This question is about Windows 10: `'export' is not recognized as an internal or external command, operable program or batch file.` – Christian May 09 '21 at 07:49
  • I missed that, thanks. I changed the answer so it appears directed to linux/mac users. – mama May 09 '21 at 08:47