2019-03-07 17:28
浏览 208


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 (

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\ 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 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: (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).


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\ 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 (

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:

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsvjw20866
    dsvjw20866 2019-03-09 15:32

    So I finally understood what the problem is with the EDIT 4 (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!

    点赞 评论