-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: update documentation for module mode #37960
Comments
|
It works for another project with |
https://github.com/rohankeskar19/whisper shows an empty repo, so that error message seems correct.
See https://blog.golang.org/using-go-modules and https://golang.org/doc/code.html for tutorials on setting up a new Go project using modules. I'm not sure if there is any |
I tried to generate bindings from my local environment, and this error occured before creating the repo, I was able to generate bindings after locally downloading all the packages required in the go-ethereum package and setting |
Your In module mode, your dependencies are determined by the main module's |
Yeah, I know I disabled it later, And even for an package which contains a simple program as
I get the same error as above when |
When working with a local module, run I successfully ran gomobile bind in modules mode
|
Ok, It works now! Thanks. |
Seems like we need to update the |
# make `gomobile` works fine with `go module` than the old `$GOPATH` mode.
# 0)
install go 1.14
# 1) unset env var for shell
unset GO111MODULE
unset GOMOD
# 2) set `go module` to `auto` for the best compatibility
go env -w GO111MODULE=auto
# 3) restart your terminal for safe
# 4) create `go module` configuration file: `go.mod` and `go.sum`
go mod init demo_android_go_mobile
# 5) build your demo go library
gomobile bind -v -o app/lib/mobile.aar -target=android ./libmobile/src/go/mobile
# 5.1) my project structure
╰─> tree .
.
├── app
│ ├── lib
│ │ ├── mobile-sources.jar
│ │ └── mobile.aar
│ └── src
│ └── java
├── go.mod
├── go.sum
└── libmobile
└── src
└── go
└── mobile
└── mobile.go
# 5.2) file `mobile.go`
package mobile
import "fmt"
func SayHello() {
fmt.Println("Hello Mobile")
}
func SayHelloWithParams(name string) {
fmt.Println("Hello", name)
}
func SayHelloWithParamsAndReturn(name string) string {
return "Hello" + name
}
func SayHelloWithParamsAndReturnAndException(name string) (string,
error) {
return "Hello" + name, fmt.Errorf("some error")
}
|
Module mode is documented in http://golang.org/wiki/Mobile. Close as this issue is outdated. |
What version of Go are you using (
go version
)?go version go1.13.6 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?package whisper
import (
"context"
"fmt"
"log"
)
func GetKeys() {
client, err := shhclient.Dial("ws://10.0.2.2:8546")
if err != nil {
log.Fatal(err)
}
keyID, err := client.NewKeyPair(context.Background())
if err != nil {
log.Fatal(err)
}
}
gomobile: C:\Users\Rohan\go\bin\gobind.exe -lang=go,java -outdir=C:\Users\Rohan\AppData\Local\Temp\gomobile-work-181241247 github.com/rohankeskar19/whisper failed: exit status 1
no exported names in the package "github.com/rohankeskar19/whisper"
no exported names in the package "github.com/rohankeskar19/whisper"
no exported names in the package "github.com/rohankeskar19/whisper"
no exported names in the package "github.com/rohankeskar19/whisper"
unable to import bind/java: go [-e -json -compiled=true -test=false -export=false -deps=false -find=true -- golang.org/x/mobile/bind/java]: exit status 2: go: finding golang.org/x/mobile latest
runtime/cgo
gcc_android.c:6:25: fatal error: android/log.h: No such file or directory
#include <android/log.h>
^
compilation terminated.
The text was updated successfully, but these errors were encountered: