简体   繁体   English

在 Android 上运行 Go 程序?

[英]Running a go program on Android?

I have a go library that i want to run on android and use its methods in my android app.我有一个 go 库,我想在 android 上运行并在我的 android 应用程序中使用它的方法。 I could write the whole android app in go to make it easier to use this dependency.我可以在 go 中编写整个 android 应用程序,以便更轻松地使用此依赖项。 Is this possible?这可能吗? If so, how?如果是这样,如何?

Download Termux (Linux Emulator) from google play store and open it.从 Google Play 商店下载 Termux (Linux Emulator) 并打开它。 Next, wait for it to perform an automatic download of its resources.接下来,等待它执行其资源的自动下载。 After that operation, the run the following command: pkg install golang pkg install git操作完成后,运行以下命令: pkg install golang pkg install git

The got package is required when downloading golang packages.下载golang包时需要got包。 Eventually, you can test it by running (go) command.最后,您可以通过运行 (go) 命令来测试它。

Golang support for mobile development has been steadily improving. Golang 对移动开发的支持一直在稳步提升。 Today it is even possible to build some simple all Go apps (depending on which features you need) as well as Go libraries.今天甚至可以构建一些简单的 Go 应用程序(取决于您需要哪些功能)以及 Go 库。 Please see https://github.com/golang/go/wiki/Mobile for more info.请参阅https://github.com/golang/go/wiki/Mobile了解更多信息。

You can use a Go library from Java when developing for Android with gobind (see this example in the gomobile repository).在使用 gobind 为 Android 开发时,您可以使用 Java 中的 Go 库(请参阅 gomobile 存储库中的 示例)。 The biggest issue with this is integration into the build system.最大的问题是集成到构建系统中。

For Go 1.5 things are getting better , but you'll have to wait for that. 对于 Go 1.5,事情变得越来越好,但你必须等待。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM