2017-02-24 163 views
4

我在Windows中使用Go版本1.7.5,并且当我尝试使用gomobile命令安装或绑定或构建。它显示这个错误 - “gomobile:没有设置Android NDK路径,请运行gomobile init,并通过Android SDK管理器安装ndk-bundle或设置-ndk标志。 我已经添加了NDK路径到系统变量$ PATH,甚至手动安装了NDK,但仍然存在错误。 感谢您的时间!gomobile命令错误“没有设置Android NDK路径”

+1

你运行'gomobile init'作为错误按摩建议? – ymonad

+1

阅读文档https://github.com/golang/mobile,似乎gomobile要求golang 1.5。使用1.7.5 – reticentroot

+0

@ymonad运行gomobile init时不会显示此错误。 –

回答

4

您需要使用-ndk标志设置NDK路径gomobile init - 如果你遵循these instructions,路径应该是~/Library/Android/sdk/ndk-bundle/

gomobile init -ndk ~/Library/Android/sdk/ndk-bundle/ 

然后你就可以编译APK:

gomobile build -target=android <PATH> 

路径应该是相对于$GOPATH/src。例如,如果你安装了基本的例子:

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

构建命令应该是:

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