gomobile¶
安装:
$ go install golang.org/x/mobile/cmd/gomobile@latest
安卓相关:
$ export ANDROID_NDK_HOME=/Users/chang/Library/Android/sdk/ndk/19.2.5345600
$ export ANDROID_HOME=/Users/chang/Library/Android/sdk
命令执行:
$ gomobile init
$ gomobile init -ndk /Users/edz/Library/Android/sdk/ndk-bundle/
$ gomobile build golang.org/x/mobile/example/basic
$ gomobile build -androidapi 21 golang.org/x/mobile/example/basic
常见问题¶
问题1¶
问题描述gomobile: ANDROID_NDK_HOME is unusable: unsupported API version 16 (not in 19..33)
问题解决:
增加选项 -androidapi 21 $ gomobile build -androidapi 21 golang.org/x/mobile/example/basic
参考:Gomobile is not compatible with modern Android SDKs and NDKs: https://github.com/golang/go/issues/52470