BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

The State of Go Language for Android Native Development

| by Sergio De Simone on Jun 27, 2014. Estimated reading time: 2 minutes |

[2014 Dec, 11 Update: Go 1.4 adds official support for Android native development]

A couple of different proposals from Google engineers and independent developers are aiming at making it possible to write native Android apps in Go. This will not go so far as allowing Go apps to access the full Android NDK, but it could allow access to a subset of it.

According to David Crawshaw, engineer at Google and author of a proposal to add partial Go support for Android apps, "providing a Go equivalent to the Android platform is intractable. The platform is written in Java and has a huge API surface."

There is however, says Crawshaw, a subset of Android apps written against a much smaller C-based API surface provided in the Android NDK: Games. Thus it becomes feasible to build Go support for Android providing the equivalent features found in the NDK.

Crawshaw proposes that during the Go 1.4 cycle, support for a GOOS=android option will be introduced to the Go repository that will include:

  • Bindings for OpenGL, OpenSL, and OpenMAX as exported through the Android NDK.
  • A Java -> Go language binding generator. Given a Go package, this will let Java code call it, so game menu UIs can be built in the standard SDK.
  • Android Studio build system integration.

Crawshaw's proposal to bring Go to Android is not the only one. Elias Naur suggests to extend Go toolchain so that it supports the creation of shared libraries. This would allow to create an Android app which uses a Go library loaded and run in Android apps as distributed in .apk files. An important requirement for this to happen has been already satisfied in Go 1.3 by adding support for cross-compilation. Cross-compilation is required because the NDK does not run on Android itself and only executables and shared libraries compiled and/or linked with the Android NDK are guaranteed to run on Android devices.

The latter proposal is based on an existing open-source project by Elias Naur, goandroid. Goandroid patches Go tools and runtime to allow the creation of shared libraries that can be run within native Android apps and is not officially supported by Google.

Finally, a more comprehensive framework that aims at allowing to write Android native applications in Go is Mandala. Mandala uses the Goandroid toolchain and according to its creator, Andrea Fazzi, thanks to Mandala "you can develop, test and run your application on your desktop and then deploy it to an Android device. It encourages the use of idiomatic Go for writing Android applications: communication happens through channels and not callbacks."

Mandala comes close to Crawshaw's proposal, feature-wise, and also aims at providing a solution mostly for games: "The framework should not be considered a high-level game engine but as a basic layer onto which game engines can be built or existing ones can be used." Fazzi warns that Google does not support native Android development in Go, but expresses his hope that "the present work could act as a sort of incentive in the direction of an official Android support by the Go Team."

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and dont miss out on content that matters to you

BT