Skip to content

Instantly share code, notes, and snippets.

@sunsheng
Forked from fangdingjun/golang_build_android.sh
Created November 19, 2016 16:16
Show Gist options
  • Save sunsheng/64fa91a1e1033454f3895069a527bd9a to your computer and use it in GitHub Desktop.
Save sunsheng/64fa91a1e1033454f3895069a527bd9a to your computer and use it in GitHub Desktop.
shell script to help to build the golang binary for android, use gomobile
#!/bin/bash
# refer to http://www.sajalkayan.com/post/go-android-binary.html
export GOMOBILE="$GOPATH/pkg/gomobile"
export GOOS=android
export GOARCH=arm
export CC=$GOMOBILE/android-ndk-r12b/arm/bin/arm-linux-androideabi-clang
export CXX=$GOMOBILE/android-ndk-r12b/arm/bin/arm-linux-androideabi-clang++
export CGO_ENABLED=1
export GOARM=7
go build -p=8 -pkgdir=$GOMOBILE/pkg_android_arm -tags="" -ldflags="-extldflags=-pie" "$@"
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment