Reputation: 469
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.
Upvotes: 1
Views: 455
Reputation: 469
I have gotten to the bottom of this in case anyone else has the issue;
It appears, at least for me, the Gradle plugin wasn't respecting the location of the GO bin. Instead it looks up the gobin using;
gobin, err := exec.LookPath("go")
I have a number of Go versions installed (for various reasons) so my forcing the gobin was failing. To discover this I have added debug logs to the env.go
file. In general the logging on the file is not the most clear when attempting to debug.
Upvotes: 1
Reputation: 1324537
This seems to be a gomobile error message, seen in 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`")
}
So double-check the value of GOPATH
between your local session and your Android Studio session.
See for instance this old (2015) thread to see if any of those comments still apply.
Upvotes: 0