I'm trying to produce aar file by run command gomobile bind as per below :
gomobile bind -target=android golang.org/x/mobile/example/bind/hello
But always, getting error like below :
gomobile: gobind -lang=go,java -outdir=/var/folders/s_/yzvdrlg522z237w58tjn2rm00000gp/T/gomobile-work-931510225 golang.org/x/mobile/example/bind/hello failed: exec: "gobind": executable file not found in $PATH
I already tried to specified path inside class GobindExtension
in GobindPlugin.groovy
as per below:
class GobindExtension {
// Package to bind. Separate multiple packages with spaces. (required)
def String pkg = "golang.org/x/mobile/example/bind/hello"
// GOPATH: necessary for gomobile tool. (required)
def String GOPATH = System.getenv("GOPATH")
// GO: path to go tool. (can omit if 'go' is in the paths visible by Android Studio)
def String GO = "/usr/local/opt/go/libexec/bin"
// GOMOBILE: path to gomobile binary. (can omit if 'gomobile' is under GOPATH)
def String GOMOBILE = "/Users/vierdamila1/Desktop/go-workspace/bin/gomobile"
}
And this is my GOPATH :
export GOPATH="/Users/vierdamila1/Desktop/go-workspace"
But still not working. Did I missed something here? Really appreciate for any kind help.
I think I found the solution, I put here for someone who might need the answer. Actually the error is showing up because I haven't install gobind. So before you do gomobile bind, don't forget to install gobind by run below command :
go install golang.org/x/mobile/cmd/gobind
after that call the bind command :
gomobile bind -target=android golang.org/x/mobile/example/bind/hello
The bind command will generate hello.aar file and you can put it inside your Android project libs folder.
gobind package install
$ go get golang.org/x/mobile/cmd/gobind
init
$ gomobile init
build
$ gomobile <build or bind> ...