commit | d77bba0a9ff855143ad5f8f2d5fa9822ed1be63e | [log] [tgz] |
---|---|---|
author | David Crawshaw <crawshaw@golang.org> | Fri Apr 17 08:05:20 2015 -0400 |
committer | David Crawshaw <crawshaw@golang.org> | Fri Apr 17 16:08:58 2015 +0000 |
tree | 4e1993dbb8230da94d7ee636c762ae22842a6534 | |
parent | 47553f4d4275316f2610b3204f8f9ecaf3ce63a7 [diff] |
app: call main.main on app startup There is some cleanup to be done in this package now, but I'm deferring it until later in the cycle. We should probably also change the semantics slightly: main should be called for all-Go apps (that is, apps that use NativeActivity), but it would be more consistent with buildmode=c-shared and c-archive if we did not call main for Go shared libraries being included in Java android apps. Change-Id: I13ca797a478edb22b0c602c1ee6e616fe4fea1e6 Reviewed-on: https://go-review.googlesource.com/9016 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.