I'm trying to generate a .aar file in Windows 7 64bits with the command gomobile bind --target=android
and it gives me the title error. I've been looking and I couldn't find an answer to this. I'm trying to make an app in Android Studio with the program and the first part of it is as follows:
package main (I changed it to "random" for the bind command to work - that's the thing to do, right?)
import (
"github.com/elazarl/goproxy"
"text/template"
"net/http"
"regexp"
"bytes"
"log"
"net"
)
The error is as follows:
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
One of the guides I'm following is https://dzone.com/articles/gomobile-library-development-for-iosandroid and it's from there I'm doing most things. I had never heard of this language, so I'm a begginer (I'm sorry if this is a dumb question).
According to what I read, this could be because there was, for example, ".\greetings" in the program (something with ".\" that had to do with relative paths), so I have no idea of why this is happening. Can someone help? If I need to provide more data, just tell me and I'll provide it.
Thanks in advance!
EDIT: I tried to change "package random" to "package thing" and the last part of the error changed "random" to "thing":
..\\[User name]\AppData\Local\Temp\gomobile-work-101707703\src\gobind\go_thingmain.go:17:2: local import "." in non-local package
Am I supposed not to be trying to convert this program because it's written in a way that cannot be converted? Or something else?
And if it helps in any way, my username in Windows has a space, though in CMD it appears with the not completed name and ~1 in the end, so it doesn't have the space at least at the return of the command. And I can't understand where those 17:2 things point to. I know it's a line and a column, but I don't know where to go look for the error since I even tried to go to the generated file and I can't find it. When I copied the folder created, only 4 or 5 files came with it and no folders, so I can't see the error in that file to understand this... Hope someone knows the answer or a possible one to this.
EDIT 2: Now I decided to try to delete all the code after the imports and only have in the .go file what is shown in the code and it gave the following error:
gomobile: C:\Users\[User name]\go\bin\gobind.exe -lang=go,java -outdir=C:\Users\[User name\AppData\Local\Temp\gomobile-work-847973191 . failed: exit status 1
no exported names in the package "."
no exported names in the package "."
no exported names in the package "."
no exported names in the package "."
And I don't have any "." in the file, so I might think the "." is referring to some package, but I have no idea, since there are only 4 and not the 7 that are imported.
And just now I deleted everything in the file except the first line saying package random
and it gives the same error as above. Any help with this? (If I need to provide more information tell me) I can't understand what's causing it, since the only examples I saw on the Internet were related to relative imports in the file. Do I have the GOPATH wrong? I have it to the default value of %USERNAME%/go
. And this was an executable. I tried to kind of convert it to library by changing the package to random. I don't know if it has anything to do with that or even if I need to change anything else to use it as a library.
EDIT 3 (too many, but I'm trying to give as much information as I can):
I tried to delete piece by piece the code until the first error changed to other and the only code in the program left was this:
package thing
func ExternalIP()
With this code it still gives the first error. If I try to delete the first line, it comes up with the error of expecting a package. But if I try to change the name of that function, even change the E to e, it gives the third error. I don't know what that name of function has of special, but I can't find "ExternalIP" name in any file on my whole computer, so I don't know what this has to do with non-local imports or something like that. If it helps, the program I'm trying to put in Android Studio is the following: https://github.com/mondul/PS3-Proxy/blob/master/ps3-proxy.go (it's not mine and I intend to give MANY credits to the person who did this, if I ever can understand how to convert it to a .aar file and then use it on Android Studio).
EDIT 4:
I tried to run that command with the file ps3-proxy.go (the file I want to convert) inside GOPATH/src/folder and it gave a different error:
gomobile: go build -buildmode=c-shared -o=C:\Users\[User Name]\AppData\Local\Temp\gomobile-work-722000459\android\src\main\jniLibs\armeabi-v7a\libgojni.so gobind failed: exit status 2
# runtime/cgo
clang.exe: error: unknown argument: '-fno-addrsig'
I don't know what this means because I can't even find something about this specific error with clang.exe on Google, so I don't know if I "solved" the main problem but created another, or if I shouldn't have put the file there, and then I come back to the main problem (even if I did it right, I have that other problem with nothing I can find about it too...).
EDIT 5 (cool, just 5 more...):
I tried another code and doing the same things on the other tests, I got the same errors as with the original program, so probably it's not program related... Amazing, now I have exactly no idea what to do. The code is the following, just in case it might be useful:
package random
import (
"math/rand"
"time"
)
func SudoRandomNumer() int {
return rand.Intn(time.Now().Second())
}
Is this a bug? I think I installed everything as it should be (well, or probably not, or this wouldn't be happening, maybe). And I've tried uninstalling and installing again about 3 times. And it still doesn't work. That code I took from a website I found with examples of how to do what I wanted to do: http://www.codingvelocity.com/2015/08/08/go-bind-intro.html.