BT

The State of Go Language for Android Native Development

by Sergio De Simone on Jun 27, 2014 |

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."

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

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT