no Android NDK found in $ANDROID_HOME/ndk-bundle nor in $ANDROID_NDK_HOME in Ubuntu 18.04 - go

I'm trying to compile native GO code for android with gomobile. Looks like gomobile is not finding ndk-build.
gomobile build -target android hello.go
gomobile: no Android NDK found in $ANDROID_HOME/ndk-bundle nor in $ANDROID_NDK_HOME
I've installed Android NDK in the ANDROID_HOME directory, changed permission on the folder to 777 and added an export entry in ~/.profile as below.
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/root/work/bin:/root/ANDROID_HOME/android-ndk-r21/ndk-build
I installed gomobile from "https://godoc.org/golang.org/x/mobile/cmd/gomobile" as:
go get golang.org/x/mobile/cmd/gomobile
"gomobile init" executes without issue; however "gomobile bind" gives the same error mesage as the gomobile build error.
I've even tried to set the env variable in the "/work/src/golang.org/x/mobile/cmd/gomobile/env.go" file as below, yet the os.GetEnv call returns blank.
os.Setenv("ANDROID_HOME", "/home/usr/ANDROID_HOME/ndk-bundle/android-ndk-r21/ndk-build")
androidHome := os.Getenv("ANDROID_HOME")
if androidHome != "" {
ndkRoot := filepath.Join(androidHome, "ndk-bundle")
_, err := os.Stat(ndkRoot)
if err == nil {
return ndkRoot, nil
}
}
The build fails no matter I run it in Ubuntu 18.04 vm or a docker container. Appreciate input and feedback.
Thanks for reading.

What worked for me when facing a similar issue was to.
Make sure the ndk-bundle folder exists in
/Users/username/Library/Android/sdk
run this
export ANDROID_NDK_HOME=/Users/username/Library/Android/sdk
run your
gomobile build -target android hello.go

Related

Failure: plugin grpc-gateway: could not find protoc plugin for name grpc-gateway -

while genrating Prot buff using "buf generate"
i am getting below error :
Failure: plugin grpc-gateway: could not find protoc plugin for name grpc-gateway - please make sure protoc-gen-grpc-gateway is installed and present on your $PATH
i have tried installtion of
"go install google.golang.org/grpc/cmd/protoc-gen-go-grpc#latest; "
$ go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway#latest
$ go install google.golang.org/protobuf/cmd/protoc-gen-go#latest
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc#latest
then check for your path , if its not set then use below command :
PATH="${PATH}:${HOME}/go/bin"
The error is specifically for protoc-genc-grpc-gateway which is distinct from proto-gen-go-grpc.
See the Installation instructions that include protoc-gen-grpc-gateway.
You will also need that the plugin is in your host's PATH. On Linux you can which protoc-gen-grpc-gateway to confirm this after installation.

underfined function error in go :jmpToFunctionValue

While running main.go getting this error in monkey file and function is given below.
bou.ke/monkey
../go/pkg/mod/bou.ke/monkey#v1.0.2/replace.go:24:14: undefined: jmpToFunctionValue
Anyone help me with that?
I also face this error while using mac M1.
could you check the goarch var in go env? if you got arm64, you need to change it to amd64 using this command
go env -w GOARCH=amd64
it works for me

Unable to Install Go-Ipfs from source

I'm trying to Build IPFS from Source on windows 10.
Previously i installed it from source.It was working fine. But i needed the latest source so i started again from the scratch. because i edited some parts in the source.
I followed instructions on https://github.com/ipfs/go-ipfs/blob/master/docs/windows.md.
I received following error on executing following commands.
code
cd %GOPATH%\src\github.com\ipfs\go-ipfs
make install
Error
go version go1.12.6 windows/amd64
bin/check_go_version 1.12
go install -asmflags=all=-trimpath="D:\GO_WORKSPACE" -gcflags=all=-trimpath="D:\GO_WORKSPACE" -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=810cb607e-dirty" ./cmd/ipfs
# github.com/ipfs/go-ipfs/plugin/loader
plugin\loader\preload.go:11:2: undefined: pluginipldgit
plugin\loader\preload.go:12:2: undefined: pluginbadgerds
plugin\loader\preload.go:13:2: undefined: pluginflatfs
plugin\loader\preload.go:14:2: undefined: pluginlevelds
make: *** [cmd/ipfs/Rules.mk:37: cmd/ipfs-install] Error 2
I tried Adding this plugins in to preload.go file under src\github.com\ipfs\go-ipfs\plugin\loader directory.
exisiting code on preload.go.
import (
"github.com/ipfs/go-ipfs/plugin"
)
i added after the issue
import (
"github.com/ipfs/go-ipfs/plugin"
pluginipldgit "github.com/ipfs/go-ipfs/plugin/plugins/git"
pluginbadgerds "github.com/ipfs/go-ipfs/plugin/plugins/git"
pluginflatfs "github.com/ipfs/go-ipfs/plugin/plugins/git"
pluginlevelds "github.com/ipfs/go-ipfs/plugin/plugins/git"
)
so after i added this lines result is success.
Executed command
make install
Result
go version go1.12.6 windows/amd64
bin/check_go_version 1.12
go install -asmflags=all=-trimpath="D:\GO_WORKSPACE" -gcflags=all=-trimpath="D:\GO_WORKSPACE" -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=810cb607e-dirty" ./cmd/ipfs
Then i tried to start the ipfs using following command
ipfs daemon
Error
Initializing daemon...
go-ipfs version: 0.4.22-dev-810cb607e-dirty
Repo version: 7
System version: amd64/windows
Golang version: go1.12.6
Error: unknown datastore type: flatfs
Can someone help me configure the IPFS from source.
Thanks in advance.
I solved this problem by following method. not sure this will be a good solution or not. any way i could solve the issue.
I'm posting this as a answer. so it will be useful to everyone who has the same issue.
1) Deleted go-ipfs folder inside the "%GO_WORKSPACE% / .... / ipfs" folder.
2) Git clone the go ipfs repo manually on the same location.
3) go inside go-ipfs folder.
4) execute install command.
make install
Done on Windows.
Save IPFS (kubo) to some folder inside %GOPATH% (I cloned https://github.com/ipfs/kubo) to folder %GOPATH%\kubo
Important cd %GOPATH%\kubo\cmd\ipfs\
go install
ipfs.exe was placed in %GOPATH%\bin
I launched it as daemon - works.
BTW: GOROOT is defined and path to go is included in PATH

Cordova/Phone Gap 2.5.0 create error

I have a problem while creating a new android project for phonegap 2.5.0. I use a Mac and set the path variables correctly. But after the command
./create /pathtoProject/PhoneGap FirstPackage CatchMyPainPG
the terminal works for about a second and then i get the following error:
An unexpected error occurred: "$ANDROID_BIN" create project --target $TARGET --path "$PROJECT_PATH" --package $PACKAGE --activity $ACTIVITY >&/dev/null exited with 1
Deleting project...
What does this mean? I think i've set the correct path variables and have all the android sdk's installed.
I hope you can help me! Thanks in advance
The package name should be prefixed accordingly with 3 namespace.
Example: com.companyname.projectname
Try this:
./create /pathtoProject/PhoneGap com.YourCompanyName.FirstPackage CatchMyPainPG
make sure you can run the commands below from your terminal:
ant -version
java -version
android -h

Error building openssl-sys crate on Windows

I am trying to compile a Rust program on Windows, but I get this error message:
Compiling openssl-sys v0.6.4
failed to run custom build command for `openssl-sys v0.6.4`
[...]
failed to execute command: The system couldn't find the specified file. (os error 2)
Is `gcc` not installed? (see https://github.com/alexcrichton/gcc-rs#windows-notes for help)
--- stderr
thread '<main>' panicked at 'explicit panic', C:\Users\User\.cargo\registry\src\github.com-0a35038f75765ae4\gcc-0.3.12\src\lib.rs:510
Cargo compiled every other package without problem, but it can't compile the openssl package.
I searched for help with this specific error and found a github issue for hyperium. The first answer references the openssl building guide for Windows.
I don't understand exactly how I have to build openssl in Windows. I installed MinGW and added the bin path to the global PATH variable, so gcc is reachable, but this did not solve the error.
I use Rust 1.2 and Cargo 0.4.0. My project is an example for a Telegram API wrapper.
1) Download ssl
Installs Win32 OpenSSL v1.0.2d
Install it here: C:\OpenSSL-Win32,C:\OpenSSL-Win32\include,C:\OpenSSL-Win32\lib
2) Install MinGW,and add system env path ,,C:\MinGW\bin,important,MinGW's installed path contain char 'MinGW '
3) cmd run env OPENSSLLIBDIR=C:/OpenSSL-Win32/lib OPENSSLINCLUDEDIR=C:/OpenSSL-Win32/include cargo build

Resources