android-studiogogomobile

Gomobile toolchain out of date, only in Android Studio


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.


Solution

  • I have gotten to the bottom of this in case anyone else has the issue;

    1. 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.