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: bind/java/seq_test.go cannot find aar on latest android studio #10668

Closed
crawshaw opened this issue May 2, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@crawshaw
Copy link
Contributor

commented May 2, 2015

When running go test, adb logcat reports:

F/go/Seq  (13579): cannot find go/Seq

It looks like go.Seq is in the testpkg.aar, but gradle is not making it part of the apk.

@timcooijmans

This comment has been minimized.

Copy link
Contributor

commented May 4, 2015

Same problem here.
The go.Seq class file is not included in the build: It is missing in the intermediate/classes directory, where I would expect it. Only the R.class file from the go java-package is present.
I tried to explicitly tell proguard not to trim the classes but that doesn't solve the problem.

@hyangah

This comment has been minimized.

Copy link
Contributor

commented May 5, 2015

@crawshaw : I could reproduce the problem myself. The class files are in the apk (so, Go.init was called) and could be found from the app package but not from bind/java package. It seems that when find_class is called from the Go thread, a wrong class loader was picked up. Verified with logging the exception details.

http://developer.android.com/training/articles/perf-jni.html#faq_FindClass
"You can get into trouble if you create a thread yourself (perhaps by calling pthread_create and then attaching it with AttachCurrentThread). Now there are no stack frames from your application. If you call FindClass from this thread, the JavaVM will start in the "system" class loader instead of the one associated with your application, so attempts to find app-specific classes will fail."

I will try to cache the loader or class from JNI_OnLoad as recommended in the doc.

@timcooijmans Is the problem related to the bind/java/seq_test.go? In seq_test.go setup, go.Seq is in build/intermediates/exploded-aar/testpkg/classes.jar.

@timcooijmans

This comment has been minimized.

Copy link
Contributor

commented May 5, 2015

@hyangah I'm seeing exactly the same problem in other projects. However both in seq_test.go and in my project I was surprised to see that the go-related Java-class-files were not present during gradle-building in the intermediate/classes directory. I expected them there but maybe I am wrong on that.

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.