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: Unable to import bind package into java file #18960

Closed
codelinter opened this issue Feb 6, 2017 · 3 comments
Closed

x/mobile/bind: Unable to import bind package into java file #18960

codelinter opened this issue Feb 6, 2017 · 3 comments

Comments

@codelinter
Copy link

codelinter commented Feb 6, 2017

Please answer these questions before submitting your issue. Thanks!

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

1.7.5

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

Windows 10 64 bit

GOPATH = D:/GoWork
GOROOT = D:/Go

What did you do?

Code below is the binding go package at D:\GoWork\src\rngo\rngo\rngo.go

Very simple, just returning a string

package rngo

// RNcall is used to bind with RN
func RNcall()  string {
	return "From Go platform"
}

Running the below command from > D:\GoWork\src\rngo

gomobile bind -target android -o rngo.aar -v  .

Verbose Output below

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\classes.go

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\classes.h

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\classes.c

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gen\src\Java\interfaces.go
rngo/rngo

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\fakegopath\pkg\android_arm\rngo\rngo.a
write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\go_rngomain.go

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\go_main.go

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\androidlib\main.go

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\android\src\main\java\rngo\Rngo.java

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\java_rngo.c

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\rngo.h

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\android\src\main\java\go\Universe.java

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\android\src\main\java\go\error.java

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\java_universe.c

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\universe.h

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\seq_android.go

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\seq_android.c

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\seq.h

write C:\Users\Minty\AppData\Local\Temp\gomobile-work-855641675\gomobile_bind\seq.go

Java
/C/Users/Minty/AppData/Local/Temp/gomobile-work-855641675/gomobile_bind command-line-arguments rngo/rngo Java

/C/Users/Minty/AppData/Local/Temp/gomobile-work-855641675/gomobile_bind command-line-arguments rngo/rngo Java

/C/Users/Minty/AppData/Local/Temp/gomobile-work-855641675/gomobile_bind command-line-arguments rngo/rngo Java

/C/Users/Minty/AppData/Local/Temp/gomobile-work-855641675/gomobile_bind

/# /C/Users/Minty/AppData/Local/Temp/gomobile-work-855641675/gomobile_bind

D:\Android\sdk\ndk-bundle\toolchains\x86_64-4.9\prebuilt\windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin\ld:
warning: skipping incompatible
D:\Android\sdk\ndk-bundle\platforms\android-21\arch-x86_64/usr/lib/liblog.so
while searching for log

D:\Android\sdk\ndk-bundle\toolchains\x86_64-4.9\prebuilt\windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin\ld:
warning: skipping incompatible
D:\Android\sdk\ndk-bundle\platforms\android-21\arch-x86_64/usr/lib/libdl.so
while searching for dl

D:\Android\sdk\ndk-bundle\toolchains\x86_64-4.9\prebuilt\windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin\ld:
warning: skipping incompatible
D:\Android\sdk\ndk-bundle\platforms\android-21\arch-x86_64/usr/lib/libc.so
while searching for c

D:\Android\sdk\ndk-bundle\toolchains\x86_64-4.9\prebuilt\windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin\ld:
warning: skipping incompatible
D:\Android\sdk\ndk-bundle\platforms\android-21\arch-x86_64/usr/lib/libdl.so
while searching for dl

command-line-arguments

aar: AndroidManifest.xml

aar: proguard.txt

aar: classes.jar

jar: META-INF/MANIFEST.MF

jar: go/LoadJNI.class

jar: go/Seq$GoObject.class

jar: go/Seq$Proxy.class

jar: go/Seq$Ref.class

jar: go/Seq$RefMap.class

jar: go/Seq$RefTracker.class

jar: go/Seq.class jar: go/Universe$proxyerror.class jar:
go/Universe.class

jar: go/error.class

jar: rngo/Rngo.class

aar: jni/armeabi-v7a/libgojni.so

aar: jni/arm64-v8a/libgojni.so

aar: jni/x86/libgojni.so

aar: jni/x86_64/libgojni.so

aar: R.txt

aar: res/

Successfully created rngo.aar since there is no error message and I can see that file at D:\GoWork\src\rngo\rngo\rngo.aar

I then manually import rngo.aar file into React Native project from android studio

  1. File > New > New Module > Import .aar/.jar Package > #give the path
    to rngo.aar#
  2. File > Project Structure > app > Dependencies >
    Module dependency > rngo.aar

What did you expect to see?

Inside IDE, in MainActivity.java I can successfully do 'import go.rngo.*;', but I cannot get 'go.rngo.Rngo.RNcall()' or 'go.rngo.Rngo;' to work

I need to access the go package rngo

enter image description here
I am doing something horribly wrong, that I cannot get this simple thing to work. I wasted whole day on google but with no avail. Hence I need help getting this to work.

What did you see instead?

Building this android app throws error 'cannot find symbol'

D:\RN\gomobile\android\app\src\main\java\com\gomobile\RngoModule.java:10:
error: cannot find symbol

import go.rngo;
^

symbol: class rngo
location: package go
1 error
:app:compileDebugJavaWithJavac FAILED

enter image description here

@codelinter codelinter changed the title x/mobile/bind: Unable to import bind package into MainActivity.java. x/mobile/bind: Unable to import bind package into java file Feb 6, 2017
@rakyll
Copy link
Contributor

rakyll commented Feb 6, 2017

/cc @eliasnaur

@rakyll rakyll added this to the Unreleased milestone Feb 6, 2017
@eliasnaur
Copy link
Contributor

Gomobile was recently changed to support the empty Java package prefix and to use it as the default.

You'll need to "import rngo..." (without "go.") to make your example work.

@codelinter
Copy link
Author

Wow thanks a lot @eliasnaur, thats it.

@golang golang locked and limited conversation to collaborators Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants