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: no current JVM #33254

Closed
CanRui-Wu opened this issue Jul 24, 2019 · 5 comments
Closed

x/mobile: no current JVM #33254

CanRui-Wu opened this issue Jul 24, 2019 · 5 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Milestone

Comments

@CanRui-Wu
Copy link

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

$ go version
go version go1.12.7 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/wucanrui/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/wucanrui/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.7/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0_/j6m36l9s0psg9xm5ggt2_b680000gp/T/go-build347025139=/tmp/go-build -gno-record-gcc-switches -fno-common" 

What did you do?

go get -u golang.org/x/mobile/cmd/...
cd $GOPATH/bin
mv gomobile /usr/local/bin
mv gobind /usr/local/bin
gomobile bind -target=android -v testpkg
gomobile bind -target=android -v ***(mypackage)

What did you expect to see?

Everything is ok.

What did you see instead?

I successfully build two aar files(testpkg.aar ***.aar).

However, both testpkg.aar and ***.aar make the app crash when using asset.Open with the log "I/GoLog: asset: no current JVM".

With API 29, the log before crash is "A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 5481 (mygoapplication), pid 4382 (mygoapplication)".

I have tested in android simulator(API 24,28,29) and real device(API 28).

Besides, I did not use (vendor, mod , dev) to manage my package. All I did is to use "go get" and "gomobile bind".

@gopherbot gopherbot added this to the Unreleased milestone Jul 24, 2019
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jul 24, 2019
@timcooijmans
Copy link
Contributor

timcooijmans commented Jul 26, 2019

This is caused by the change to make gomobile Android-Q compatible. Can you try to provide the ApplicationContext by using the static method Seq.setContext(Context context) before getting the assets?

@CanRui-Wu
Copy link
Author

This is caused by the change to make gomobile Android-Q compatible. Can you try to provide the ApplicationContext by using the static method Seq.setContext(Context context) before getting the assets?

Thank you. I add Seq.setContext(getApplicationContext()) and it works. Do I have to set the context in my app? Why this cannot automatic done by gomobile?

@timcooijmans
Copy link
Contributor

timcooijmans commented Jul 29, 2019

Yes you have to set the context (at least) once in your app or library (for example in the Application.onCreate()-method.

There is no (allowed) method to get the ApplicationContext as a library (such as a gobind-based library). The only option is to let the application provide a reference on initialization of the library. This is now implemented in Seq.setContext(Context context).
Previously gomobile used reflection to statically get the ApplicationContext by using a non-published method. However this method is blacklisted in Android-Q causing warnings and exceptions.

@CanRui-Wu
Copy link
Author

Yes you have to set the context (at least) once in your app or library (for example in the Application.onCreate()-method.

There is no (allowed) method to get the ApplicationContext as a library (such as a gobind-based library). The only option is to let the application provide a reference on initialization of the library. This is now implemented in Seq.setContext(Context context).
Previously gomobile used reflection to statically get the ApplicationContext by using a non-published method. However this method is blacklisted in Android-Q causing warnings and exceptions.

Thank you very much for detail instruction. BTW, I find the file 'bind_iosapp.go' do not handle the assets subdirectory. Then, I get an error 'no such file or directory' when I still use asset.Open api in IOS. How can I use asset in IOS by using golang?

@timcooijmans
Copy link
Contributor

I'm sorry I'm not familiar with the asset package on iOS. Please open another issue describing your issue (try to provide an example reproducing the problem) and close this ticket as this issue is resolved.

@golang golang locked and limited conversation to collaborators Jul 28, 2020
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

3 participants