Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile: build of example _reverse_ failed #18210

Closed
nikolay-turpitko opened this issue Dec 6, 2016 · 5 comments
Closed

x/mobile: build of example _reverse_ failed #18210

nikolay-turpitko opened this issue Dec 6, 2016 · 5 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Milestone

Comments

@nikolay-turpitko
Copy link

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
Copy link
Contributor

rsc commented Jan 4, 2017

/cc @crawshaw

@rsc rsc modified the milestones: Unplanned, Unreleased Jan 4, 2017
@tfriedel6
Copy link

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?

@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jul 20, 2017
@Nutomic
Copy link

Nutomic commented Oct 10, 2017

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

syncthing/syncthing-android#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
Copy link
Contributor

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
Copy link

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

@golang golang locked and limited conversation to collaborators Mar 16, 2019
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
The reverse bindings allow access to Java and ObjC APIs by importing
Java/... and Objc/... package from Go. The gobind tool automatically
create the bindings for the API referenced from the packages.

The reverse example takes that ability too far, however. It creates
a circular dependency from the Android databinding layout files to
exported Go types while those same Go types access the Java classes
generated by databinding. It works almost by accident, but not for
newer Gradle versions.

The circular dependencies are bad, but the underlying circular references
created by using the reverse bindings this way are worse. I haven't found
a satisfactory was to avoid retaining references to Go objects from Java
and back without carefully and manually breaking cycles at appropriate
times. One might succeed in ObjC where breaking reference cycles are
already necessary, but not in Java.

The reverse example is a nice technical feat, but promises more than
it can deliver. Delete it.

Fixes golang/go#19862
Fixes golang/go#18210

Change-Id: Ie6abd2a0ebd4c4ce36339d1294898e15f22f83bd
Reviewed-on: https://go-review.googlesource.com/101155
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
The reverse bindings allow access to Java and ObjC APIs by importing
Java/... and Objc/... package from Go. The gobind tool automatically
create the bindings for the API referenced from the packages.

The reverse example takes that ability too far, however. It creates
a circular dependency from the Android databinding layout files to
exported Go types while those same Go types access the Java classes
generated by databinding. It works almost by accident, but not for
newer Gradle versions.

The circular dependencies are bad, but the underlying circular references
created by using the reverse bindings this way are worse. I haven't found
a satisfactory was to avoid retaining references to Go objects from Java
and back without carefully and manually breaking cycles at appropriate
times. One might succeed in ObjC where breaking reference cycles are
already necessary, but not in Java.

The reverse example is a nice technical feat, but promises more than
it can deliver. Delete it.

Fixes golang/go#19862
Fixes golang/go#18210

Change-Id: Ie6abd2a0ebd4c4ce36339d1294898e15f22f83bd
Reviewed-on: https://go-review.googlesource.com/101155
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

6 participants