在Android上运行Go程序?

huangapple go评论86阅读模式
英文:

Running a go program on Android?

问题

我有一个 Go 库,我想在 Android 上运行并在我的 Android 应用程序中使用它的方法。我可以使用 Go 编写整个 Android 应用程序,以便更容易使用这个依赖项。这种做法可行吗?如果可以,应该如何操作?

英文:

I have a go library that i want to run on android and use its methods in my android app. I could write the whole android app in go to make it easier to use this dependency. Is this possible? If so, how?

答案1

得分: 6

Golang对移动开发的支持一直在稳步提升。现在甚至可以构建一些简单的全Go应用程序(取决于你需要哪些功能),以及Go库。请参阅https://github.com/golang/go/wiki/Mobile获取更多信息。

更新:为了进一步改进,正在创建支持移动平台上UI的库。https://fyne.io为移动提供了相当强大的功能集。

英文:

Golang support for mobile development has been steadily improving. Today it is even possible to build some simple all Go apps (depending on which features you need) as well as Go libraries. Please see https://github.com/golang/go/wiki/Mobile for more info.

UPDATE: In further improvement, libraries are being created to support even UI on mobile platforms. https://fyne.io provides rather robust set of features for mobile.

答案2

得分: 6

从Google Play商店下载Termux(Linux模拟器)并打开它。
接下来,等待它自动下载资源。完成后,运行以下命令:
pkg install golang
pkg install git

在下载golang包时需要got包。
最后,可以通过运行(go)命令进行测试。

英文:

Download Termux (Linux Emulator) from google play store and open it.
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

The got package is required when downloading golang packages.
Eventually, you can test it by running (go) command.

答案3

得分: 2

你可以在使用gobind(请参考gomobile存储库中的此示例)为Android开发时,从Java中使用Go库。这样做的最大问题是将其集成到构建系统中。

对于Go 1.5来说,情况正在变得更好,但你需要等待相关更新。

英文:

You can use a Go library from Java when developing for Android with gobind (see this example in the gomobile repository). 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.

huangapple
  • 本文由 发表于 2015年2月27日 01:01:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/28748361.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定