commit | 717c2c43126e4d1b55ee187d52f72272276065e4 | [log] [tgz] |
---|---|---|
author | Burcu Dogan <jbd@google.com> | Tue Apr 21 14:51:13 2015 -0700 |
committer | Burcu Dogan <jbd@google.com> | Fri Apr 24 23:59:43 2015 +0000 |
tree | 25745c120a2b84c80312b6a340e73a1d69f2812f | |
parent | a4bb1057ff4905058139f7d4c7206cb85b55bd25 [diff] |
example/basic: add build instructions for gomobile This CL also removes Android build system required files and keeping it to the bare minimum to what gomobile requires. Fixes #10523. Change-Id: Iabf16e7ea040a74eaf64746e7cc4e23ef3683af2 Reviewed-on: https://go-review.googlesource.com/9204 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
The Go mobile repository holds packages and build tools for using Go on Android.
This is early work and the build system is a bumpy ride. Building a binary for Android requires using a Go cross compiler and an external linker from the NDK.
For now, the easiest way to setup a build environment is using the provided Dockerfile:
docker pull golang/mobile
Get the sample applications.
go get -d golang.org/x/mobile/example/...
In your app directory under your $GOPATH
, copy the following files from either the golang.org/x/mobile/example/basic or golang.org/x/mobile/example/libhello apps:
AndroidManifest.xml all.bash build.xml jni/Android.mk make.bash
Start with basic
if you are writing an all-Go application (that is, an OpenGL game) or libhello if you are building a .so
file for use from Java via gobind. Edit the files to change the name of your app.
To build, run:
docker run -v $GOPATH/src:/src golang/mobile /bin/bash -c 'cd /src/your/project && ./make.bash'
Note the use of -v option to mount $GOPATH/src to /src of the container. The above command will fail if the -v option is missing or the specified volume is not accessible from the container.
When working with an all-Go application, this will produce a binary at $GOPATH/src/your/project/bin/name-debug.apk
. You can use the adb tool to install and run this app. See all.bash for an example.
APIs are currently very limited, but under active development. Package documentation serves as a starting point:
Contributions to Go are appreciated. See https://golang.org/doc/contribute.html.