I am using Go version 1.7.5 in windows and when i am trying to use gomobile command either to install or bind or build . It displays this error- "gomobile: no Android NDK path is set. Please run gomobile init with the ndk-bundle installed through the Android SDK manager or with the -ndk flag set." I have added NDK path to system variable $PATH and even installed NDK manually but still the error persist. Thanks for your time !!
Asked
Active
Viewed 8,965 times
9
-
1did you run `gomobile init` as the error massage suggests? – ymonad Feb 24 '17 at 04:36
-
1Reading the docs https://github.com/golang/mobile, it seems gomobile requires golang 1.5. Your using 1.7.5 – reticentroot Feb 24 '17 at 04:43
-
@ymonad while running gomobile init this error is not displayed . – Sahil Chaudhary Feb 24 '17 at 10:08
-
@reticentroot I have installed golang 1.5 now but now while running gomobile command it shows "gomobile: Go 1.7 or newer is required" – Sahil Chaudhary Feb 24 '17 at 10:19
-
1@SahilChaudhary it looks like you have to do something like `gomobile init -ndk /path/to/your/android/ndk` – ymonad Feb 24 '17 at 11:05
-
@ymonad It worked now but during gomobile build command no apk is generated . Can you help with that ? – Sahil Chaudhary Feb 24 '17 at 11:44
-
@SahilChaudhary maybe you should post another question. – ymonad Feb 24 '17 at 11:46
-
Thanks for your time :-) – Sahil Chaudhary Feb 24 '17 at 11:59
-
did it work for Go 1.7 or newer ? – Scott Stensland Mar 11 '17 at 15:10
-
@ScottStensland Yes, I myself tried it for Go 1.7.5 . – Sahil Chaudhary Mar 15 '17 at 10:18
1 Answers
15
You need to set the NDK path in gomobile init
using the -ndk
flag - if you follow these instructions, the path should be ~/Library/Android/sdk/ndk-bundle/
:
gomobile init -ndk ~/Library/Android/sdk/ndk-bundle/
Then you can compile the APK:
gomobile build -target=android <PATH>
The path should be relative to $GOPATH/src
. For example, if you install the basic example:
go get -d golang.org/x/mobile/example/basic
The build command should be:
gomobile build -target=android golang.org/x/mobile/example/basic

Guilherme Garnier
- 2,208
- 23
- 22