| OLD | NEW |
| (Empty) |
| 1 # Go support for Mobile devices | |
| 2 | |
| 3 The Go mobile repository holds packages and build tools for using Go on Android. | |
| 4 | |
| 5 This is early work and the build system is a bumpy ride. Building a binary for | |
| 6 Android requires using a Go cross compiler and an external linker from the NDK. | |
| 7 | |
| 8 For now, the easiest way to setup a build environment is using the provided | |
| 9 Dockerfile: | |
| 10 | |
| 11 docker pull golang/mobile | |
| 12 | |
| 13 Get the sample applications. | |
| 14 | |
| 15 go get -d golang.org/x/mobile/example/... | |
| 16 | |
| 17 In your app directory under your `$GOPATH`, copy the following files from either | |
| 18 the [golang.org/x/mobile/example/basic](https://github.com/golang/mobile/tree/ma
ster/example/basic) | |
| 19 or [golang.org/x/mobile/example/libhello](https://github.com/golang/mobile/tree/
master/example/libhello) | |
| 20 apps: | |
| 21 | |
| 22 AndroidManifest.xml | |
| 23 all.bash | |
| 24 build.xml | |
| 25 jni/Android.mk | |
| 26 make.bash | |
| 27 | |
| 28 Start with `basic` if you are writing an all-Go application (that is, an OpenGL
game) | |
| 29 or libhello if you are building a `.so` file for use from Java via | |
| 30 [gobind](https://godoc.org/golang.org/x/mobile/cmd/gobind). Edit the files to ch
ange | |
| 31 the name of your app. | |
| 32 | |
| 33 To build, run: | |
| 34 | |
| 35 docker run -v $GOPATH/src:/src golang/mobile /bin/bash -c 'cd /src/your/
project && ./make.bash' | |
| 36 | |
| 37 Note the use of -v option to mount $GOPATH/src to /src of the container. | |
| 38 The above command will fail if the -v option is missing or the specified | |
| 39 volume is not accessible from the container. | |
| 40 | |
| 41 When working with an all-Go application, this will produce a binary at | |
| 42 `$GOPATH/src/your/project/bin/name-debug.apk`. You can use the adb tool to insta
ll | |
| 43 and run this app. See all.bash for an example. | |
| 44 | |
| 45 -- | |
| 46 | |
| 47 APIs are currently very limited, but under active development. Package | |
| 48 documentation serves as a starting point: | |
| 49 | |
| 50 - [mobile/app](http://godoc.org/golang.org/x/mobile/app) | |
| 51 - [mobile/gl](http://godoc.org/golang.org/x/mobile/gl) | |
| 52 - [mobile/sprite](http://godoc.org/golang.org/x/mobile/sprite) | |
| 53 - [mobile/cmd/gobind](http://godoc.org/golang.org/x/mobile/cmd/gobind) | |
| 54 | |
| 55 Contributions to Go are appreciated. See https://golang.org/doc/contribute.html. | |
| OLD | NEW |