golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.07k stars 17.68k forks source link

x/mobile: build of example _reverse_ failed #18210

Closed nikolay-turpitko closed 6 years ago

nikolay-turpitko commented 7 years ago

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.7.3 linux/amd64

java -version openjdk version "1.8.0_111" OpenJDK Runtime Environment (build 1.8.0_111-8u111-b14-2ubuntu0.16.04.2-b14) OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)

What operating system and processor architecture are you using (go env)?

GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/nick/go" GORACE="" GOROOT="/home/nick/.local/share/umake/go/go-lang" GOTOOLDIR="/home/nick/.local/share/umake/go/go-lang/pkg/tool/linux_amd64" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build237209226=/tmp/go-build -gno-record-gcc-switches" CXX="g++" CGO_ENABLED="1

What did you do?

If possible, provide a recipe for reproducing the error. A complete runnable program is good. A link on play.golang.org is best.

First of all, build of golang.org/x/mobile/example/basic works for me on both phone and PC.

go get golang.org/x/mobile/cmd/gobind
export ANDROID_HOME=/home/nick/Android/Sdk/
cd $GOPATH/src/golang.org/x/mobile/example/reverse/android
gradle gomobileDebug --debug

What did you expect to see?

Successful build

What did you see instead?

13:27:41.105 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
13:27:41.105 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command '/home/nick/go/bin/gobind'.
13:27:41.106 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
13:27:41.106 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
13:27:41.106 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command '/home/nick/go/bin/gobind''
13:27:43.591 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.591 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.592 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.592 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.592 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.592 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.593 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.593 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.593 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.593 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.594 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.595 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.596 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.596 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.597 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.597 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.597 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.597 [ERROR] [system.err] unsupported basic type: invalid type
13:27:43.598 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
13:27:43.598 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command '/home/nick/go/bin/gobind'' finished with exit value 1 (state: FAILED)
13:27:43.599 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
13:27:43.599 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':gobindDebug'
13:27:43.599 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] :gobindDebug FAILED
13:27:43.600 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :gobindDebug (Thread[Daemon worker Thread 3,5,main]) completed. Took 2.499 secs.
13:27:43.600 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationWorkerRegistry] Worker root.1 completed (0 in use)
13:27:43.600 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 3,5,main]] finished, busy: 2.499 secs, idle: 0.0 secs
13:27:43.602 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
13:27:43.602 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
13:27:43.602 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
13:27:43.602 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
13:27:43.602 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':gobindDebug'.
13:27:43.602 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Process 'command '/home/nick/go/bin/gobind'' finished with non-zero exit value 1
13:27:43.602 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
13:27:43.603 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
13:27:43.603 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. 
13:27:43.603 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] 
13:27:43.603 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED
rsc commented 7 years ago

/cc @crawshaw

tfriedel6 commented 7 years ago

I am currently getting the same error. After some digging, I found that the gobind command cannot resolve the imports in the go files when GOOS is set to "android". This can be easily determined adding some output to the error handler function here:

https://github.com/golang/mobile/blob/master/cmd/gobind/main.go#L110

Looking further, it seems that both the gobind and the gomobile command make use of the "go/importer" package, but gomobile creates a fake GOPATH so that the imports can be resolved, gobind however does not.

https://github.com/golang/mobile/blob/master/cmd/gomobile/bind.go#L684

This is strange though, since it apparently works for others, so I'm stumped at this point. Does anyone have any ideas?

Nutomic commented 7 years ago

I'm getting the same issue, with go1.9 linux/amd64. Code and output:

https://github.com/syncthing/syncthing-android/pull/959 https://gist.github.com/Nutomic/4fd51a707886f1b01ac5ca4eff68de95

Btw #21319 is about the same issue, but claims that it was fixed with go 1.9 (which I am using).

eliasnaur commented 7 years ago

It works for me with ./gradlew installDebug from the reverse directory. Do you have the latest checkout of golang.org/x/mobile and have run go install golang.org/x/mobile/cmd/... recently?

gopherbot commented 6 years ago

Change https://golang.org/cl/101155 mentions this issue: example/reverse: delete