1

I am working with the latest gomobile, Go, and Android Studio builds.

When I run the gradle tasks from the terminal they work as expected and build the correct binaries, however from within Android Studio I receive an error:

bin/gomobile: toolchain out of date, run `gomobile init`

Of course I have re run gomobile init many times and no change. My assumption is that Android Studio is using some config that I can not identify.

I appreciate this is a somewhat edge case question, but if anyone can point me in the right direction it would be helpful.

TLDR; ./gradlew myproj:bind works fine in terminal, fails in Android Studio.

4

2 回答 2

1

如果其他人有问题,我已经深入了解了;

  1. 看来,至少对我来说,Gradle 插件不尊重 GO bin 的位置。相反,它使用以下方式查找 gobin;

            gobin, err := exec.LookPath("go")
    

我安装了许多 Go 版本(出于各种原因),所以我强制 gobin 失败了。为了发现这一点,我在env.go文件中添加了调试日志。通常,在尝试调试时,文件上的日志记录并不是最清楚的。

于 2017-02-26T04:25:05.830 回答
0

这似乎是一条 gomobile 错误消息,见于cmd/gomobile/env.go#L69-L83

// Find gomobilepath.
gopath := goEnv("GOPATH")
for _, p := range filepath.SplitList(gopath) {
    gomobilepath = filepath.Join(p, "pkg", "gomobile")
    if _, err := os.Stat(gomobilepath); buildN || err == nil {
        break
    }
}

verpath := filepath.Join(gomobilepath, "version")
installedVersion, err := ioutil.ReadFile(verpath)
if !bytes.Equal(installedVersion, version) {
    return nil, errors.New("toolchain out of date, run `gomobile init`")
}

因此,请仔细检查GOPATH本地会话和 Android Studio 会话之间的值。
例如,请参阅这个旧的(2015 年)线程,看看这些评论是否仍然适用。

于 2017-02-26T01:42:36.520 回答