Skip to content

x/mobile: go package name conflict with type name #18689

@brcomunique

Description

@brcomunique

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

Danilos-MacBook-Pro:golibdemo danilolr$ go version
go version go1.7.3 darwin/amd64

What operating system and processor architecture are you using (go env)?

Danilos-MacBook-Pro:golibdemo danilolr$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/danilolr/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.3/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ry/l4yf7vwd5rbdydhtn03qfmnm0000gn/T/go-build870546491=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

I create a new package to be used as a gomobile library.
The package contains only one file (golibdemo.go) with this content :

package golibdemo

import "fmt"

type GoLibDemo struct {
}

func main() {
d := GoLibDemo{}
fmt.Println(d)
}

Then I execute the command :

gomobile bind -target android

What did you expect to see?

The .aar file build.

What did you see instead?

A error message and a zero size aar file :

Danilos-MacBook-Pro:golibdemo danilolr$ gomobile bind -target android
gomobile: javac -d /var/folders/ry/l4yf7vwd5rbdydhtn03qfmnm0000gn/T/gomobile-work-713371376/javac-output -source 1.7 -target 1.7 -bootclasspath /Users/danilolr/Library/Android/sdk/platforms/android-24/android.jar go/LoadJNI.java go/Seq.java go/Universe.java go/error.java golibdemo/Golibdemo.java failed: exit status 1
golibdemo/Golibdemo.java:9: error: class GoLibDemo is public, should be declared in a file named GoLibDemo.java
public final class GoLibDemo implements Seq.Proxy {
^
./golibdemo/Golibdemo.java:9: error: class GoLibDemo is public, should be declared in a file named GoLibDemo.java
public final class GoLibDemo implements Seq.Proxy {
^
golibdemo/Golibdemo.java:10: error: cannot access Golibdemo
static { Golibdemo.touch(); }
^
bad source file: ./golibdemo/Golibdemo.java
file does not contain class golibdemo.Golibdemo
Please remove or make sure it appears in the correct subdirectory of the sourcepath.
3 errors

Danilos-MacBook-Pro:golibdemo danilolr$ ls -l
total 8
-rw-r--r-- 1 danilolr staff 0 Jan 17 17:09 golibdemo.aar
-rw-r--r-- 1 danilolr staff 110 Jan 17 16:51 golibdemo.go
Danilos-MacBook-Pro:golibdemo danilolr$

Please say me more

The problem only happens when building the library to android on OSX.
I am able to build it to android on linux and to iOS on OSX.

Activity

added this to the Unreleased milestone on Jan 17, 2017
eliasnaur

eliasnaur commented on Mar 16, 2018

@eliasnaur
Contributor

I believe this is a dup of #23327, which is fixed.

locked and limited conversation to collaborators on Mar 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bradfitz@rakyll@eliasnaur@gopherbot@brcomunique

        Issue actions

          x/mobile: go package name conflict with type name · Issue #18689 · golang/go