Android Apps in Go
Download and install each from Google. I've stored them here:
/usr/local/android-sdk
/usr/local/android-ndk
If you don't want to run things as root, take ownership of these directories.
export SDK_ROOT=/usr/local/android-sdk
export NDK_ROOT=/usr/local/android-ndk
export PATH="${PATH}:${SDK_ROOT}/tools"
export PATH="${PATH}:${SDK_ROOT}/platform-tools"
$ sudo $NDK_ROOT/build/tools/make-standalone-toolchain.sh --install-dir=$NDK_ROOT --arch=arm --toolchain=arm-linux-androideabi-4.9 --platform=android-21
Most of this comes from this doc.
Install in /usr/local/go1.4. You'll need it to build Go 1.5.
Install in /usr/local/go. If you already have Go 1.5 installed, go
ahead and rebuild it anyway (from HEAD of master). Things are being
fixed rapidly and it's worth the update.
export GOPATH=${HOME}/go
export GOROOT=/usr/local/go
export GOROOT_BOOTSTRAP=/usr/local/go1.4
export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"
Download and install gomobile:
$ go get github.com/golang/mobile/cmd/gomobile
$ sudo apt-get -y install libgles2-mesa-dev libegl1-mesa-dev
Might require NDK toolchain
$ cd $GOROOT/src
$ CC_FOR_TARGET=$NDK_ROOT/bin/arm-linux-androideabi-gcc GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 ./make.bash --no-clean
This will download, build, and install the basic example app.
The previous CC_FOR_TARGET setting can cause issues for linux/amd64 builds. Set it back to default:
$ cd $GOROOT/src
$ CC_FOR_TARGET= GOOS=linux GOARCH=amd64 ./make.bash --no-clean
$ go install golang.org/x/mobile/example/basic
$ basic
$ go get -d golang.org/x/mobile/example/basic
$ gomobile build golang.org/x/mobile/example/basic
$ gomobile install golang.org/x/mobile/example/basic
build: build apk file for this project
install: copy apk file to /mnd/sdcard/golang on phone