Skip to content
This repository has been archived by the owner. It is now read-only.
Go-SDL2 example running on Android
Java Shell Go Makefile C
Branch: master
Clone or download
Latest commit 657b2a2 Nov 18, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
android update Go download url Sep 9, 2016
example Add other arches, improve build scripts May 10, 2016
gradle/wrapper Add gradle support May 15, 2016
AUTHORS
COPYING initial commit Mar 22, 2016
README.md Update README.md Nov 18, 2018
build.gradle Add gradle support May 15, 2016
gradlew Add gradle support May 15, 2016
settings.gradle Add gradle support May 15, 2016

README.md

Go-SDL2 Android Example

Deprecated by https://github.com/veandco/go-sdl2-examples/tree/master/examples/android !

Go-SDL2 example running on Android.

Golang example is compiled to C shared library and then linked with the help of Android.mk files from SDL2.

SDLActivity.java is used, same as with C/C++ and SDL2.

Download APK

go-sdl2-example-1.1-debug.apk

Compile

To compile example you will need Android NDK and Android SDK , download and unpack archives somewhere.

Go toolchain must be cross compiled for android. There is a bootstrap script in android dir that you can use to compile toolchains and SDL2 for arm, arm7, arm64, x86 and x86_64.

Make sure you have git, mercurial/hg and curl installed.

Export paths to Android NDK and SDK:

export ANDROID_NDK=/opt/android-ndk
export ANDROID_SDK=/opt/android-sdk

If you want to use clang instead of gcc:

export USE_LLVM=1

Bootstrap Go and SDL:

cd android
./bootstrap.bash /usr/local

/usr/local is prefix where Go and Android toolchains will be installed.

After build is complete point GOROOT to new Go installation in /usr/local:

export GOROOT=/usr/local/go

And export paths to android toolchains, so scripts can find them:

export ANDROID_TOOLCHAIN_ARM=/usr/local/android-toolchain-arm
export ANDROID_TOOLCHAIN_ARM7=/usr/local/android-toolchain-arm7
export ANDROID_TOOLCHAIN_ARM64=/usr/local/android-toolchain-arm64
export ANDROID_TOOLCHAIN_X86=/usr/local/android-toolchain-x86
export ANDROID_TOOLCHAIN_X86_64=/usr/local/android-toolchain-x86_64

To build apk with ant:

cd android
./mkapk-ant.bash

To build apk with gradle:

cd android
./mkapk-gradle.bash

If everything is successfully built apk can be found in android/build directory.

You can also import project in Android Studio so you can use CPU monitor, debugger etc. but note that you have to rebuild Go library every time you make changes. You can rebuild like this:

cd android
./mklib.bash arm arm7 arm64 x86 x86_64
You can’t perform that action at this time.