分享
GO语言已经可以写Android项目了,你知道吗?
q26335804 · · 16372 次点击 · · 开始浏览这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。
新的库名叫go.mobile,包含了Go for Android的库的工具
在go.mobile库的readme中有介绍开发环境的搭建,不过仅限于早期版本,整合进IDE的构建系统还没有呢。
- 首先需要Android SDK,和NDK。
- 然后需要添加一个环境变量:NDK_ROOT=$HOME/android/ndk-toolchain
- 配置NDK工具ndk/build/tools/make-standalone-toolchain.sh -platform=android-9 --install-dir=$NDK_ROOT
- 安装Go cross-compiler
- hg clone https://code.google.com/p/go
- cd go/src
- CC_FOR_TARGET=$NDK_CC GOOS=android GOARCH=arm GOARM=7 ./make.bash
- 如果之前有安装过GO,那默认情况下是for电脑平台的,所以这里要构建ARM的。大概是这个意思。
- 将go/bin添加到path环境变量中
Apps are written in Java, developed using the standard Android
tools, that include a Go library for added functionality. There is an
example of such a library in go.mobile/example/libhello.
To build the shared library, use the make.bash script in the example's
directory. It requires an environment variable, ANDROID_APP, set to the
location of your Android studio project. E.g.
ANDROID_APP=$HOME/android/studio/yourapp/app
With this variable, make.bash builds the .so file and symlinks in the
necessary java files to the project.
Go Android apps (games)
-------------
Go Android apps are built on top of the NDK's NativeActivity. These apps
are written entirely in Go. An example of such an app, with touch events
and OpenGL, is in go.mobile/example/basic.
To build and deploy the app to the device currently attached to adb,
use the all.bash script in the example's directory. It requires
ndk-build, ant, and adb on your PATH.
APIs are currently very limited, but under active development.
To submit changes to this repository, see http://golang.org/doc/contribute.html.
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信16372 次点击
添加一条新回复
(您需要 后才能回复 没有账号 ?)
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
新的库名叫go.mobile,包含了Go for Android的库的工具
在go.mobile库的readme中有介绍开发环境的搭建,不过仅限于早期版本,整合进IDE的构建系统还没有呢。
- 首先需要Android SDK,和NDK。
- 然后需要添加一个环境变量:NDK_ROOT=$HOME/android/ndk-toolchain
- 配置NDK工具ndk/build/tools/make-standalone-toolchain.sh -platform=android-9 --install-dir=$NDK_ROOT
- 安装Go cross-compiler
- hg clone https://code.google.com/p/go
- cd go/src
- CC_FOR_TARGET=$NDK_CC GOOS=android GOARCH=arm GOARM=7 ./make.bash
- 如果之前有安装过GO,那默认情况下是for电脑平台的,所以这里要构建ARM的。大概是这个意思。
- 将go/bin添加到path环境变量中
Apps are written in Java, developed using the standard Android
tools, that include a Go library for added functionality. There is an
example of such a library in go.mobile/example/libhello.
To build the shared library, use the make.bash script in the example's
directory. It requires an environment variable, ANDROID_APP, set to the
location of your Android studio project. E.g.
ANDROID_APP=$HOME/android/studio/yourapp/app
With this variable, make.bash builds the .so file and symlinks in the
necessary java files to the project.
Go Android apps (games)
-------------
Go Android apps are built on top of the NDK's NativeActivity. These apps
are written entirely in Go. An example of such an app, with touch events
and OpenGL, is in go.mobile/example/basic.
To build and deploy the app to the device currently attached to adb,
use the all.bash script in the example's directory. It requires
ndk-build, ant, and adb on your PATH.
APIs are currently very limited, but under active development.
To submit changes to this repository, see http://golang.org/doc/contribute.html.