gomobile

1. 确保mac上安装了go

2. 安装android sdk

3. Android ndk安装

选择ndk14及以上版本

下载参考:https://blog.csdn.net/momo0853/article/details/73898066或

https://blog.csdn.net/shuzfan/article/details/52690554

下载后到路径下赋予操作权限:chmod a+x android-ndk-r14b-darwin-x86_64

然后terminal命令行执行: ./android-ndk-r14b-darwin-x86_64

在上一步的sdk中新建ndk-bundle文件夹,把文件拷贝进去

4. 环境变量配置:

export ANDROID_HOME=/Users/edz/Android/sdk

5. gomobile安装

执行 go get golang.org/x/mobile/cmd/gomobile

或者把github上的gomobile copy到$GOPATH/src/golang.org/x下面

6. 生成sdk

在gopath的src下新建hello文件夹,里面新建hello.go文件

到$GOPATH /bin下面执行 gomobile bind -target=android hello 如下:

gomobile bind -o hello.aar -target=android golang.org/x/mobile/example/bind/hello

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

猜你喜欢

转载自www.cnblogs.com/sunnykwan/p/11541220.html
今日推荐