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: reverse binding not working anymore? #50608

Open
timcooijmans opened this issue Jan 14, 2022 · 3 comments
Open

x/mobile: reverse binding not working anymore? #50608

timcooijmans opened this issue Jan 14, 2022 · 3 comments
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@timcooijmans
Copy link
Contributor

timcooijmans commented Jan 14, 2022

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

$ go version
go version go1.17.6 linux/amd64

$ gomobile version
golang.org/x/mobile/cmd/gomobile@latest

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
 go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/root/sdk/go1.17.6"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/root/sdk/go1.17.6/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/build2/go.mod"
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-build2412464046=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Create a file in a module that uses reverse binding:

package gomobiletest


import (
        "log"
        "Java/android/content"
)

func Test(androidctx content.Context)  {
        apkPath := androidctx.GetPackageResourcePath()
        log.Println(appPath)
}

and run

gomobile bind

What did you expect to see?

A successful compile

What did you see instead?

A successful compile with the method ignored.

@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jan 14, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jan 14, 2022
@heschi heschi added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 20, 2022
@heschi
Copy link
Contributor

heschi commented Jan 20, 2022

cc @hyangah

@gtf35
Copy link

gtf35 commented Jan 23, 2022

There was a demo before ( https://github.com/golang/mobile/tree/37c5126484a7fd3b7987809e9f68f1ba4e7a5341/example/reverse), but it was build with gradle plugin,

It was removed because it couldn't have stable access to the xml layout in Android, but more often, we just want to call some Java methods (for some reasons, I have to do this, such as get android id in go)

Android Studio support language C , but not support Golang, IDEA support Golang, but not support C :(

So I don't want to use CGo(jni) to done it

I'm out of options now

@sll00
Copy link

sll00 commented Sep 11, 2023

I also need this, and was dishearted to see it ghosted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants