GO语言已经可以写Android项目了,你知道吗?

新的库名叫go.mobile,包含了Go for Android的库的工具

在go.mobile库的readme中有介绍开发环境的搭建,不过仅限于早期版本,整合进IDE的构建系统还没有呢。

  1. 首先需要Android SDK,和NDK。
  2. 然后需要添加一个环境变量:NDK_ROOT=$HOME/android/ndk-toolchain
  3. 配置NDK工具ndk/build/tools/make-standalone-toolchain.sh -platform=android-9 --install-dir=$NDK_ROOT
  4. 安装Go cross-compiler
    1. hg clone https://code.google.com/p/go
    2. cd go/src
    3. CC_FOR_TARGET=$NDK_CC GOOS=android GOARCH=arm GOARM=7 ./make.bash
  5. 如果之前有安装过GO,那默认情况下是for电脑平台的,所以这里要构建ARM的。大概是这个意思。
  6. 将go/bin添加到path环境变量中
利用Go,可以开发两种项目,一种是android JAVA代码调用到go,另一种就是纯Go写的APP,第二种就是提供了open gl和完全的golang开发环境。


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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值