Giter VIP home page Giter VIP logo

kaori-android's Introduction

Go-SDL2 Android Example

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

kaori-android's People

Contributors

gen2brain avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.