go version)?$ go version: go1.12.4 linux/amd64 $ go mobile version: gomobile version +cafc553 Mon Aug 26 17:01:11 2019 +0000 (android); androidSDK=/home/--/Android/Sdk/platforms/android-28
Yes, the issue is produced only on the latest gomobile version.
go env)?go env Output
$ go env
GOARCH="amd64"
GOBIN="/usr/local/go"
GOCACHE="/home/--/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="My Go path"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build242944229=/tmp/go-build -gno-record-gcc-switches"
Trying to generate the java binding for my go file:
Error:
gomobile bind -o ~/test.aar -target=android -androidapi=23 test || exit 1
gomobile: $GOPATH/bin/gobind -lang=go,java -outdir=/tmp/gomobile-work-628614164 test failed: exit status 1
2019/08/27 09:51:37 go [list -e -json -compiled=true -test=false -export=false -deps=true -find=false -tags -- test]: exit status 2: # runtime/cgo
gcc_android.c:6:25: fatal error: android/log.h: No such file or directory
compilation terminated.
Error in generating the java binding.
Note: Before updating the gomobile same code was building.
Hello @hajimehoshi ,
Yesterday your patch got merged:
https://github.com/golang/mobile/commit/cafc553e1ac52dc290ac711ed9b891bb4fcc1b4c
Before that, gomobile bind was working.
Can you please please let me know, what update I have to make to gobind command ?
Hi,
I'm not sure your question, but my last patch should fix some bugs and gobind should work (as long as go module is not used).
Could you try gomobile with GO111MODULE=off?
@hajimehoshi ,
Now, I removed the gomobile and gobind from my system completely. (src and bin folder)
Now, I tried freshly to do:
go get golang.org/x/mobile/cmd/gomobile
But following error is coming:
package golang.org/x/mobile/cmd/gomobile: cannot find package "golang.org/x/mobile/cmd/gomobile" in any of:
/usr/local/go/src/golang.org/x/mobile/cmd/gomobile (from $GOROOT)
/home/jay/go/src/golang.org/x/mobile/cmd/gomobile (from $GOPATH)
Any idea ?
@jay11ca39 You can try the following order, to see if that helps (still GO111MODULE=off):
go get golang.org/x/mobile/cmd/gobind
go get golang.org/x/mobile/cmd/gomobile
gomobile init
@torbenschinke
Thanks for your reply..
I tried the suggested way, but it is also giving the same error:
go get golang.org/x/mobile/cmd/gobind
package golang.org/x/mobile/cmd/gobind: cannot find package "golang.org/x/mobile/cmd/gobind" in any of:
/usr/local/go/src/golang.org/x/mobile/cmd/gobind (from $GOROOT)
/home/jay/go/src/golang.org/x/mobile/cmd/gobind (from $GOPATH)
I have one basic query regarding: GO111MODULE=off
How to make sure it is off ?
Is it a flag we have to give while doing go get ?
For example:
GO111MODULE=off go get golang.org/x/mobile/cmd/gobind
Is it a flag we have to give while doing go get ?
It is safe to give GO111MODULE=off explicitly when go-getting gomobile/gobind. My guess is that you did go-get with modules. Then try:
GO111MODULE=off go get golang.org/x/mobile/cmd/gobind
GO111MODULE=off go get golang.org/x/mobile/cmd/gomobile
gomobile init
EDIT: module-aware go-get also installs binaries under $GOPATH/bin, so golang.org/x/mobile/cmd/gobind should work. 🤔
I am using gomobile for couple of months.. I used to give:
go get golang.org/x/mobile/cmd/gomobile
go get golang.org/x/mobile/cmd/gobind
As you see above commands, I do not have use GO111MODULE flag.
But today when I am tried it is failing I am not sure what is the cause..
This issue is raised for gobind on latest gomobile version.
but now it became go get issue. :(
Edit:
@hajimehoshi
You are correct, previously I did not use GO111MODULE=off flag, then as suggested by you, I tried with that flag. But now, I think it is failing to do go get on other packages as well.
For example: go get github.com/axw/gocov/gocov is also failing.
How can I fix this go get ?
I have the same issue, running inside a docker (debian:stretch-slim).
If it would be of any help, you can try it out here: https://hub.docker.com/r/blixtwallet/blixtwallet/
This is the Dockerfile: https://github.com/hsjoberg/blixt-wallet/blob/35a904cf1f9c6a5da74ecdd4e09dbf5ee6fae24b/Dockerfile
We're having the same issue (gcc_android.c:6:25: fatal error: android/log.h: No such file or directory) @jay11ca39 initially reported. I can also confirm the problem started once https://github.com/golang/mobile/commit/cafc553e1ac52dc290ac711ed9b891bb4fcc1b4c was merged. If I revert that commit, all is well
Edit: note that we're not using Go modules
I can also confirm the problem started once golang/mobile@cafc553 was merged.
I was wondering if the previous commit https://github.com/golang/mobile/commit/30c70e3810e97d051f18b66d59ae242540c0c391 worked on your environment.
I could not reproduce the issue. The latest gomobile worked on my MacBook Pro:
$ gomobile version
gomobile version +cafc553 Mon Aug 26 17:01:11 2019 +0000 (android,ios); androidSDK=/Users/hajimehoshi/Library/Android/sdk/platforms/android-28
Hello @rayvbr ,
How did you revert to the old commit ?
Are you building gomobile from source, I mean cloning and building or
Is there is any option in go get to take a specific version ?
cc @hajimehoshi
@jay11ca39
You can use any version of gomobile by using git:
cd $GOPATH/go/src/golang.org/x/mobile
git checkout [version]
go install ./cmd/...
I had the same issue.
After reverting back to 30c70e3810e97d051f18b66d59ae242540c0c391 everything works again.
OK I think I found the solution: could you try
go get -u golang.org/x/tools
? https://go-review.googlesource.com/c/tools/+/190339 should be the necessary change.
OK I think I found the solution: could you try
go get -u golang.org/x/tools? https://go-review.googlesource.com/c/tools/+/190339 should be the necessary change.
I tried this (with modules enabled and disabled) but that doesn't seem to work.
Updating all tools with go get -u golang.org/x/tools/... also doesn't help.
I can confirm, that reverting back to 30c70... also worked for us
Thanks. It looks like this happens when the default driver is not used. I am not familiar with drivers...
@HeavyHorst do you have gopackagesdriver command in $PATH, or did you specify $GOPACKAGESDRIVER?
@matloob If an external driver in go/packages is used, the fix https://go-review.googlesource.com/c/tools/+/190339 is not applied. Is my understanding correct? I was wondering if there is a workaround.
CC @hyangah
@HeavyHorst do you have
gopackagesdrivercommand in$PATH, or did you specify$GOPACKAGESDRIVER?
No, neither one nor the other.
Hmm, thanks.
Updating all tools with
go get -u golang.org/x/tools/...also doesn't help.
Could you tell me the Git hash of $GOPATH/src/golang.org/x/tools? ~If you did go get with enabling Go modules, this might not be updated.~ Sorry you said you did with and without modules...
Thanks for investigating.
The hash is: b29f5f60c37a1dd56e6942c2717b85b976e4a592
Let me know if you need anything else.
@HeavyHorst
Thanks! Could you try
cd $GOPATH/src/golang.org/x/mobile
GOPACKAGESDRIVER=off GO111MODULE=off go test -v -run=TestGobind/Go-Cgopkg -count=1 ./cmd/gobind
and tell me the result?
GOPACKAGESDRIVER=off GO111MODULE=off go test -v -run=TestGobind/Go-Cgopkg -count=1 ./cmd/gobind
=== RUN TestGobind
=== RUN TestGobind/Go-Cgopkg
--- FAIL: TestGobind (0.28s)
--- FAIL: TestGobind/Go-Cgopkg (0.28s)
gobind_test.go:82: gobind -lang go,java,objc golang.org/x/mobile/bind/testdata/cgopkg failed: exit status 1: 2019/08/28 12:52:09 go [list -e -json -compiled=true -test=false -export=false -deps=true -find=false -tags -- golang.org/x/mobile/bind/testdata/cgopkg]: exit status 2: # runtime/cgo
gcc_android.c:6:10: schwerwiegender Fehler: android/log.h: No such file or directory
6 | #include <android/log.h>
| ^~~~~~~~~~~~~~~
Kompilierung beendet.
FAIL
FAIL golang.org/x/mobile/cmd/gobind 0.791s
Not sure if that helps but when i readd this line: Env: append(os.Environ(), "CGO_ENABLED=0"),
to cmd/gobind/main.go everything works again.
I guess this condition is suspicious: the error message might not be exactly 2 lines. Probably the stderr of ~gobind -lang go,java,objc golang.org/x/mobile/bind/testdata/cgopkg > /dev/null~ GOOS=android go list -e -json -compiled=true -test=false -export=false -deps=true -find=false -tags -- golang.org/x/mobile/bind/testdata/cgopkg > /dev/null has 4 lines in your environment.
Not sure if that helps but when i readd this line: Env: append(os.Environ(), "CGO_ENABLED=0"),
to cmd/gobind/main.go everything works again.
Thanks! Though this suppresses the error, I don't think this is a correct fix since go/packages would miss some files for Cgo.
Hm, I don't see any error if I run go list directly in the terminal:
rkaufmann î‚° rkaufmann î‚° ~ î‚° % î‚° GOPACKAGESDRIVER=off GO111MODULE=off GOOS=android go list -e -json -compiled=true -test=false -export=false -deps=true -find=false -tags -- golang.org/x/mobile/bind/testdata/cgopkg > /dev/null
rkaufmann î‚° rkaufmann î‚° ~ î‚° % î‚°
GOPACKAGESDRIVER=off GO111MODULE=off go test -v -run=TestGobind/Go-Cgopkg -count=1 ./cmd/gobind
=== RUN TestGobind
=== RUN TestGobind/Go-Cgopkg
--- FAIL: TestGobind (0.27s)
--- FAIL: TestGobind/Go-Cgopkg (0.27s)
gobind_test.go:82: gobind -lang go,java,objc golang.org/x/mobile/bind/testdata/cgopkg failed: exit status 1: 2019/08/28 13:37:31 go [list -e -json -compiled=true -test=false -export=false -deps=true -find=false -tags -- golang.org/x/mobile/bind/testdata/cgopkg]: exit status 2: # runtime/cgo
gcc_android.c:6:10: schwerwiegender Fehler: android/log.h: No such file or directory
6 | #include <android/log.h>
| ^~~~~~~~~~~~~~~
Kompilierung beendet.
FAIL
FAIL golang.org/x/mobile/cmd/gobind 0.748s
FAIL
Sry, I had to enable cgo with export CGO_ENABLED=1.
After that go list prints this error:
# runtime/cgo
gcc_android.c:6:10: schwerwiegender Fehler: android/log.h: No such file or directory
6 | #include <android/log.h>
| ^~~~~~~~~~~~~~~
Kompilierung beendet.
@HeavyHorst Thank you for confirming! I think that's the cause and we should fix go/packages.
@matloob :
As we discussed here, there are two problems in go/packages:
What do you think?
Just to confirm:
rkaufmann  rkaufmann  ~  go  …  golang.org  x  mobile  master  ERROR  %  GOPACKAGESDRIVER=off GO111MODULE=off go test -v -run=TestGobind/Go-Cgopkg -count=1 ./cmd/gobind :(
=== RUN TestGobind
=== RUN TestGobind/Go-Cgopkg
--- FAIL: TestGobind (0.28s)
--- FAIL: TestGobind/Go-Cgopkg (0.28s)
gobind_test.go:82: gobind -lang go,java,objc golang.org/x/mobile/bind/testdata/cgopkg failed: exit status 1: 2019/08/28 14:09:52 go [list -e -json -compiled=true -test=false -export=false -deps=true -find=false -tags -- golang.org/x/mobile/bind/testdata/cgopkg]: exit status 2: # runtime/cgo
gcc_android.c:6:10: schwerwiegender Fehler: android/log.h: No such file or directory
6 | #include <android/log.h>
| ^~~~~~~~~~~~~~~
Kompilierung beendet.
FAIL
FAIL golang.org/x/mobile/cmd/gobind 0.729s
FAIL
I then removed strings.Count(stderr.String(), "\n") == 2 from /home/rkaufmann/go/src/golang.org/x/tools/go/packages and everything seem to work afterwards
rkaufmann  rkaufmann  ~  go  …  golang.org  x  mobile  master  ERROR  %  GOPACKAGESDRIVER=off GO111MODULE=off go test -v -run=TestGobind/Go-Cgopkg -count=1 ./cmd/gobind :(
=== RUN TestGobind
=== RUN TestGobind/Go-Cgopkg
--- PASS: TestGobind (1.68s)
--- PASS: TestGobind/Go-Cgopkg (1.68s)
PASS
ok golang.org/x/mobile/cmd/gobind 2.143s
Change https://golang.org/cl/191942 mentions this issue: go/packages: ignore Cgo compilation error correctly
I am getting this problem
gcc_android.c:6:10: fatal error: 'android/log.h' file not found
and from the above am not clear what I have to do to fix it
gomobile version +d9e324c Sat Nov 23 05:49:42 2019 +0000 (android); androidSDK=/Users/davidsteed/Library/Android/sdk/platforms/android-28
XXXX-Mac:~ XXXXhi$ go get golang.org/x/mobile/cmd/gobind
go: finding golang.org/x/mobile latest
XXXX-Mac:~ XXXXhi$ go get golang.org/x/mobile/cmd/gomobile
go: finding golang.org/x/mobile latest
XXXX-Mac:~ XXXXhi$ gomobile init
gomobile: /usr/local/go/bin/go install golang.org/x/mobile/cmd/gobind failed: exit status 1
go/src/golang.org/x/mobile/internal/importers/ast.go:37:2: cannot find package "golang.org/x/tools/go/packages" in any of:
/usr/local/go/src/golang.org/x/tools/go/packages (from $GOROOT)
/Users/XXXXhi/go/src/golang.org/x/tools/go/packages (from $GOPATH)
go get golang.org/x/mobile/cmd/tools
go: finding golang.org/x/mobile latest
go get golang.org/x/mobile/cmd/tools: module golang.org/x/mobile@upgrade found (v0.0.0-20191123054942-d9e324ca8c38), but does not contain package golang.org/x/mobile/cmd/tools
@stonedreamforest try this
go get -u golang.org/x/tools/...