{"id":13796282,"url":"https://github.com/xlab/android-go","last_synced_at":"2025-05-16T07:03:52.761Z","repository":{"id":57483291,"uuid":"58981472","full_name":"xlab/android-go","owner":"xlab","description":"The android-go project provides a platform for writing native Android apps in Go programming language.","archived":false,"fork":false,"pushed_at":"2022-11-06T20:40:36.000Z","size":458,"stargazers_count":1067,"open_issues_count":15,"forks_count":79,"subscribers_count":63,"default_branch":"master","last_synced_at":"2024-10-29T19:58:16.716Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://developer.android.com/ndk/index.html","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-17T01:51:35.000Z","updated_at":"2024-10-28T00:17:20.000Z","dependencies_parsed_at":"2022-08-27T20:02:41.629Z","dependency_job_id":null,"html_url":"https://github.com/xlab/android-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fandroid-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fandroid-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fandroid-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fandroid-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xlab","download_url":"https://codeload.github.com/xlab/android-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247878022,"owners_count":21011158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T23:01:08.358Z","updated_at":"2025-04-08T16:07:57.597Z","avatar_url":"https://github.com/xlab.png","language":"Go","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"android-go [![Go Report Card](https://goreportcard.com/badge/github.com/xlab/android-go)](https://goreportcard.com/report/github.com/xlab/android-go) ![Lines of Code](https://img.shields.io/badge/lines-7K-blue.svg)\n==========\n\nThe **android-go** project aims to provide a platform (namely an SDK) for\nwriting native Android apps in Go programming language. All things here were\ndesigned to be less coupled as possible, thus maintaining a great level of\nflexibility while keeping things simple and easy to use. The approach and tools\nare different from [gomobile](https://github.com/golang/mobile), please\ndistinguish them apart.\n\nThe project was one of [the best Go Newsletter items of 2016](http://golangweekly.com/issues/140). In this final issue of the year, they look back at the most popular Go news and links of 2016. 🌟\n\n❗️Important! Please see [cmd/android-project](/cmd/android-project) utility that replaces the original `android` from SDK that has been stripped in latest SDK releases. All example Makefiles were updated, I advise you to do the same rather than stick to old SDK versions.\n\n## Project structure\n\n### android [![GoDoc](https://godoc.org/github.com/xlab/android-go/android?status.svg)](https://godoc.org/github.com/xlab/android-go/android)\n\nPackage **android** provides Go bindings for the Android NDK API. They've been\nautomatically generated by [c-for-go](https://git.io/c-for-go) using the\nofficial NDK headers from `android-23` platform. Keep in mind that different NDK\nplatforms may implement different sets of API available, thus some of features\nused by this binding may not be available in older versions of platform. But I\ntested with the `android-21` toolchain and got no issues. Some files, like\n[android/sensors.go] for example, have been written by hand to expose some\nfeatures that CGO does not handle well.\n\nThis package allows to write code that works directly with NDK API, bypassing\nall the CGO bookkeeping and boilerplate bloat in your code. But safety is\nstrictly advised. There is also a JNI calling mechanism that allows easy interactions with\nJava VM and exposes the full potential of Android SDK! See [android/jni_util.go] for example\nof toggling Android keyboard and other JNI-based utils.\n\n**Example usages:** [app/queue.go], [example], [example-egl], [nk-android].\n\n[app/queue.go]: https://github.com/xlab/android-go/blob/master/app/queue.go\n[android/jni_util.go]: https://github.com/xlab/android-go/blob/master/android/jni_util.go\n[android/sensors.go]: https://github.com/xlab/android-go/blob/master/android/sensors.go\n\n### cmd/android-project\n\nTool **android-project** is a simple replacement for infamous `android` util from Android SDK, prior to Android SDK Tools [Revision 25.3.0 (March 2017) release](https://developer.android.com/studio/releases/sdk-tools.html) when they dropped that util abruptly and got back a stripped version later. Needs to be installed first:\n\n```\ngo get github.com/xlab/android-go/cmd/android-project\n```\n\n### app [![GoDoc](https://godoc.org/github.com/xlab/android-go/app?status.svg)](https://godoc.org/github.com/xlab/android-go/app)\n\nPackage **app** implements a NativeActivity glue layer required to properly\nhandle the startup process and the native activity events. Import this package\ninto your Go application to make it Android-compatible. Some pieces required\nfor a proper `main.main` trampoline have been borrowed from gomobile, the\nabsolute minimum to get this stuff invokable as a native activity. Most of the\ncode in this package provides wrappers around NativeActivity event callbacks.\n\n**Example usages:** [example], [example-egl], [nk-android].\n\n[example]: https://github.com/xlab/android-go/tree/master/example\n[example-egl]: https://github.com/xlab/android-go/tree/master/example-egl\n\n### egl [![GoDoc](https://godoc.org/github.com/xlab/android-go/egl?status.svg)](https://godoc.org/github.com/xlab/android-go/egl)\n\nPackage **egl** provides Go bindings for EGL API. They've been automatically\ngenerated by [c-for-go](https://c-for-go.com) using the official NDK headers\nfrom `android-23` platform. All functions have their reference to the offical\nKhronos documentation. Some files, like [egl/errors.go] for example, have been\nwritten by hand to expose some features that would make it more idiomatic in the\nGo world.\n\nExamples of usage in conjuction with the **android** package: [example-egl], [nk-android].\n\n[egl/errors.go]: https://github.com/xlab/android-go/blob/master/egl/errors.go\n\n### gles [![GoDoc](https://godoc.org/github.com/xlab/android-go/gles?status.svg)](https://godoc.org/github.com/xlab/android-go/gles)\n\nPackage **gles** provides Go bindings for the OpenGL ES v1 API. They've been\nautomatically generated by [c-for-go](https://c-for-go.com) using the\nofficial NDK headers from `android-23` platform. All functions have their\nreference to the offical documentation.\n\nExample of usage in conjuction with the **android** package: [example-egl].\n\n### gles2 [![GoDoc](https://godoc.org/github.com/xlab/android-go/gles2?status.svg)](https://godoc.org/github.com/xlab/android-go/gles2)\n\nPackage **gles2** provides Go bindings for the OpenGL ES v2 API. They've been\nautomatically generated by [c-for-go](https://c-for-go.com) using the\nofficial NDK headers from `android-23` platform. All functions have their\nreference to the offical documentation.\n\nExample of usage in conjuction with the **android** package: [nk-android].\n\n### gles3 [![GoDoc](https://godoc.org/github.com/xlab/android-go/gles3?status.svg)](https://godoc.org/github.com/xlab/android-go/gles3)\n\nPackage **gles3** provides Go bindings for the OpenGL ES v3 API. They've been\nautomatically generated by [c-for-go](https://c-for-go.com) using the\nofficial NDK headers from `android-23` platform. All functions have their\nreference to the offical documentation.\n\nExample of usage in conjuction with the **android** package: [nk-android].\n\n### gles31 [![GoDoc](https://godoc.org/github.com/xlab/android-go/gles31?status.svg)](https://godoc.org/github.com/xlab/android-go/gles31)\n\nPackage **gles31** provides Go bindings for the OpenGL ES v3.1 API. They've been\nautomatically generated by [c-for-go](https://c-for-go.com) using the\nofficial NDK headers from `android-23` platform. All functions have their\nreference to the offical documentation. The OpenGL ES computing API is supported.\n\n## Examples\n\nRefer the example links to get more info about them.\n\nThere are three examples. The first [example] is a template app showing how\nto create and build an Android application using the absolute minimum of code and\nboilerplate. It also shows the primitives of an activity and how to handle\nactivity events, there is no visual part, so be ready to read the lines from the\nADB logcat. If this one works correctly on your device, my congratulations. If\nnot, please open an issue.\n\nThe [example-egl] leverages all three packages together: **android**, **egl**\nand of course **gles** (OpenGL ES 1.0) to create an visual app that animates its color based\non the accelerometer values. It also reads input events such as key events and\nmultitouch motion events (with pressure, if supported by the device), you can\ncheck these events in the ADB logcat. Please see the video of the expected\nbehaviour:\n\n[![Golang + EGL/GLES App on Android](https://img.youtube.com/vi/H2cafzATUEw/0.jpg)](https://www.youtube.com/watch?v=H2cafzATUEw)\n\nAnd recently I took [nuklear] package and implemented a few backends in Go,\nincluding two for Android that initialize OpenGL ES 2 or ES 3 context using\n**android**, **egl**, **gles2** and **gles3** packages. They also responsible\nfor handling touch and other input events. So now it is possible to create GUI\napps for Android, see [nk-android] for an example Nuklear GUI app.\n\n[nuklear]: http://github.com/golang-ui/nuklear\n[nk-android]: https://github.com/golang-ui/nuklear/tree/master/cmd/nk-android\n\n[![Nuklear GUI App written in Golang runs on Android](https://img.youtube.com/vi/3-MiceegZlM/0.jpg)](https://www.youtube.com/watch?v=3-MiceegZlM)\n\nAndroid keyboard toggling [video](https://goo.gl/photos/TFkYFKC48Re6RnbUA).\n\n## On existing tools or why not just use Gomobile\n\n**TL;DR** it's a \"three wheel bicycle\" in terms of hacking flexibility. Conversely, this\nproject tries to fill the niche by providing a platform that is minimal as\npossible and respects the bleeding-edge features such as OpenGL ES 3.1, ES 3.2\nand of course Vulkan API.\n\nGoMobile has different aims and motivation with a lot of implications. First of\nall, it has been grown as a bootstrap-script. That's it: a tool with a lot of\nhardcoded logic that helped to popularize Go on mobile platforms. Still provides a\nsimple way to start building Android and iOS apps in no time, without diving\ndeeply into any of the platform-specific complications. It provides a lot of wrappers and\nhelpers that abstract all the platform-related boilerplate and logic away,\nmaking your apps look the same on any platform: Android, iOS, PC (Linux/OS\nX/Windows).\n\nAlso, considering that binding feature of GoMobile, it's a good option to use\nwhen you already have lots of Java/Obj-C code and want to integrate some of Go\nlibs into the project. The tool is mostly for experienced mobile developers who\njust want to try Go sometimes. They provide a framework that hides platform\ndetails, but they also may be to restrictive and limited due to this and can't\nbe used for crazy experimenting stuff.\n\nAn example: for Android developent, gomobile defaults to `r10` SDK with `android-15`\nstripped-down NDK, there is a lot of code written to automate this process and\nthere is no way to override this environment, even by rewriting a lot of\ngomobile bootstrapping code. It's a great mess. I wasted too much time trying to\nswitch to the `r12-beta1` SDK and the `android-23` NDK platform. Instead of providing\na good document how to build the Go-based apps and incorporate them into any of\nthe existing development process, GoMobile project introduces tons of\nhardcoded scripts.\n\n## Contributing\n\nFeel free to share bugs, I expect a lot of weird cases. Please also share this\nproject in social networks so more people would know how to write Go apps for\nAndroid that are not limited.\n\n## License\n\nAll the code except when stated otherwise is licensed under the [MIT license](/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlab%2Fandroid-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxlab%2Fandroid-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlab%2Fandroid-go/lists"}