GO语言学习:go语言实现android应用的步骤
go语言在1.4版本就提供了编辑android应用的功能,但当时最简单的方法是使用docker来配置,而且在编辑和导入过程也不是很方便。
在go语言1.5以后提供了gomobile工具,使用该工具后,仅需几步就可以配置编辑环境,而且编辑和导入也很方便。
参考:https://github.com/golang/go/wiki/Mobile
以下为window环境下的步骤
1. 安装gomobile工具
$go get golang.org/x/mobile/cmd/gomobile
→ 如果无法访问golang.org,可以访问https://github.com/golang/mobile,直接下载源程序,并将mobile文件夹拷贝到在 $GOPATH/src/golang.org/x/ 下
执行 $go build golang.org/x/mobile/cmd/gomobile
$go install golang.org/x/mobile/cmd/gomobile
完成后可以在 $GOPATH/bin 下可以发现 gomobile.exe 生成
2.配置编译环境
$gomobile init
在这步中需要访问https://dl.google.com 下载ndk,由于被墙无法访问,这一步就需要自己翻墙搞定
3. 编译
以编辑example/basic为例
$gomobile build -target=android golang.org/x/mobile/example/basic
4. 导入手机
首先ADB是肯定要在你的电脑上安装过的,并且确认ADB已经识别出你的手机
$gomobile install golang.org/x/mobile/example/basic
这时你就可以在你的手机上找到basic应用了
更多推荐
所有评论(0)