一,环境搭建
1、安装Go
a. 下载地址为: https://golang.org/dl/
b. 这里下载到的版本为 go 1.5.2.windows-amd64.zip
c. 然后将压缩包里面的go文件夹解压到D盘根目录
d. 配置环境变量GOROOT和GOPATH
e. GOROOT值为D:/go
f. 新建文件夹D:/GOPATH
g. 设置环境变量GOPATH值为D:/GOPATH
h. 在PATH环境变量中增加 ;%GOROOT%/bin;%GOPATH%/bin
2、安装go mobile
$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 生成
3、关联Android ndk (建议使用Android tudio下载)
$gomobile init -v 你的ndk的目录
4、编写go程序,我随便写了段
package goTestfunc
Add(x int, y int) int {
return x + y
}
Go语言里要注意下,函数必须首字母大写的才能导出,否则无法导出
命令行里,先cd到你.go文件所在目录,然后执行命令
gomobile bind -target=android
运行完后会生成一个.aar文件
打开android studio,新建项目,建好后在左边项目面板中选中你的项目右键new,选择Module,选择导入jar/aar,选中第5步里创建的aar文件。
在Project Structure中将导入的Module添加到创建的项目Dependencies中。
8 、 参考文档
https://blog.csdn.net/HJLAllen1/article/details/51920170
https://blog.csdn.net/phlong999/article/details/49613931
https://blog.csdn.net/lanyu19950216/article/details/50456732
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- Go语言-打包静态文件
- 【前端打包部署】谈一谈我在SPA项目打包=>部署的处理
- Maven多模块项目打包前的一些注意事项(打包失败)
- tar打包如何不打包某一个文件夹(排除某些文件夹)
- iOS新手用swift写一个macos打包工具 一键打包到指定位置
- Android应用签名打包
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Intersectional Internet
Safiya Umoja Noble、Brendesha M. Tynes / Peter Lang Publishing / 2016
From race, sex, class, and culture, the multidisciplinary field of Internet studies needs theoretical and methodological approaches that allow us to question the organization of social relations that ......一起来看看 《The Intersectional Internet》 这本书的介绍吧!
Base64 编码/解码
Base64 编码/解码
HEX HSV 转换工具
HEX HSV 互换工具