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/cmd/gomobile: local import "." in non-local package #30691

Closed
Edw590 opened this issue Mar 8, 2019 · 5 comments
Closed

x/mobile/cmd/gomobile: local import "." in non-local package #30691

Edw590 opened this issue Mar 8, 2019 · 5 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Edw590
Copy link

Edw590 commented Mar 8, 2019

What did you do?

I'm trying to convert a program (which is not mine) to .aar with gomobile with the command gomobile bind --target=android to use on Android Studio. The program is on GitHub: https://github.com/mondul/PS3-Proxy/blob/master/ps3-proxy.go.

What did you expect to see?

I don't exactly know, but probably I would expect a .aar file to appear somewhere.

What did you see instead?

The following error:

gomobile: go build -buildmode=c-shared -o=C:\Users\\[User name]\AppData\Local\Temp\gomobile-work-101707703\android\src\main\jniLibs\armeabi-v7a\libgojni.so gobind failed: exit status 1
..\\[User name]\AppData\Local\Temp\gomobile-work-101707703\src\gobind\go_randommain.go:17:2: local import "." in non-local package

System details

go version go1.12 windows/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="C:\Users\[User name]\AppData\Local\go-build"
GOEXE=".exe"
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="windows"
GOOS="windows"
GOPATH="C:\Users\[User name]\go"
GOPROXY=""
GORACE=""
GOROOT="C:\Go"
GOTMPDIR=""
GOTOOLDIR="C:\Go\pkg\tool\windows_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
GOROOT/bin/go version: go version go1.12 windows/amd64
GOROOT/bin/go tool compile -V: compile version go1.12

Notes

I had never heard of the language until I saw this program and my need for it, so I don't completely understand it. Though, I've been reading and I couldn't find anything on the Internet that solves that error.

The program works perfectly when I run it on my Android phone with GNURoot Debian (since I have KitKat and Termux only works with at least Lollipop) and at least it shows signals of being working by printing the first line when I run it with the command go run ps3-proxy.go on CMD on Windows (I'm using Windows 7 if that helps).

For the command to be able to work, I changed the first line of the file from package main to package random (that's why the name of the file on the error is go_randommain.go. That's the right thing to do right?

Any help is much appreciated. Thanks in advance!

@andybons andybons changed the title gomobile: local import "." in non-local package x/mobile/cmd/gomobile: local import "." in non-local package Mar 8, 2019
@gopherbot gopherbot added this to the Unreleased milestone Mar 8, 2019
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Mar 8, 2019
@andybons andybons modified the milestones: Unreleased, Unplanned Mar 8, 2019
@andybons
Copy link
Member

andybons commented Mar 8, 2019

@hyangah @crawshaw

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 8, 2019
@Edw590
Copy link
Author

Edw590 commented Mar 8, 2019

I don't know if it would help, but I'll put a link to the same question I posted on StackOverflow yesterday. As not many people were viewing it (not a really big community), I thought in asking here too. But there I write somethings I've done to try to understand the problem with no success, so I thought maybe it might be useful for someone to see them, so here is the link to the question: https://stackoverflow.com/questions/55049699/how-to-local-import-in-non-local-package-error. I updated it just now with putting the ps3-proxy.go file into GOPATH/src/folder and running the command, but that gives another error which I have no idea of what means because Google can't find it and I don't know if I should have put it there, and if I should, then I created another error/issue...:
gomobile: go build -buildmode=c-shared -o=C:\Users\EDUARD~1\AppData\Local\Temp\gomobile-work-722000459\android\src\main\jniLibs\armeabi-v7a\libgojni.so gobind failed: exit status 2 [hashtag] runtime/cgo clang.exe: error: unknown argument: '-fno-addrsig'

@Edw590
Copy link
Author

Edw590 commented Mar 9, 2019

Ok, so I think I may have found a possible bug. If it's not, then I have no idea why it happened with me. This is what I wrote in StackOverflow:

So I finally understood what the problem is with the EDIT 4 [from StackOverflow, to put the .go program in GOPATH\src\folder] (and I think it was the right thing to do, at least in my case)... Since it was probably not related with any program and it said on the error that might have to do clang.exe, I went looking for it and found out it is inside the ndk-bundle folder. That folder I downloaded from the official website, renamed it and put it in my Android SDK Tools folder and used it. I don't know why I didn't download it from Android Studio, but I didn't. So after knowing the file was inside the folder I downloaded externally and not from inside Android Studio, I deleted everything and redownloaded the NDK Bundle, but this time from Android Studio (and just in case might be useful to know, I downloaded every other thing that is shown when we click to show obsolete packages), and it finally worked! Then to be sure the problem was me having downloded it from outside of Android Studio, I used that downloaded version again and it gave the same clang.exe error. And after that, trying again with the version downloaded from Android Studio it worked again. So this might be a bug or something like that, because at least for me it only works with the Android Studio NDK Bundle version and not with the downloaded from their website. This is weird, but at least it's finally working.

Now I just can't understand why I have to put ALL the files I want to convert inside GOPATH\src\[a folder] for they to work and don't give me the non-local thing error (btw, in my case, my GOPATH is C:\Users\[User Name]\go, in case might be useful to know)... Both programs (the one from GitHub and the other from the website with the tutorial) have to be put in a path like that to be converted and can't be converted outside of it. That's weird. I don't know if it's supposed to be like that, but at least it's working...

Hope this helps someone else having this problem!

@jaceee
Copy link

jaceee commented Jul 5, 2019

I seem to get this error every time I work outside GOPATH with go modules.
Moving package to the appropriate place in GOPATH seems to make it work again.

@andybons
Copy link
Member

Hi there,
We have decided that our experiment to allow questions on the issue tracker has not had the outcome we desired, so I am closing this issue. I'm sorry that we can't answer your question here.

There are many other methods to get help if you're still looking for answers:

Thanks

@golang golang locked and limited conversation to collaborators Aug 11, 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 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants