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: some .aar's import and build in android studio but some dont #30192

Closed
mandelmonkey opened this issue Feb 12, 2019 · 8 comments

Comments

Projects
None yet
5 participants
@mandelmonkey
Copy link

commented Feb 12, 2019

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

go1.11.4 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/a/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/a/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.4/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/nv/r_25ssyx3k70hy55hrzghc2c0000gn/T/go-build837618377=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

ran "$GOPATH/bin/gomobile" bind -target=android -tags="android" -v -o "$android_dest" "$package"
and imported the .aar into Android Studio

What did you expect to see?

Should be able to import via

File ➤New ➤New Module ➤Import .JAR or .AAR package
File ➤Project Structure ➤app ➤Dependencies ➤Add Module Dependency

Should be able to build

What did you see instead?

Import did not show as a module but managed to hack by manually importing
After that project fails to build in android studio

Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :lndmobile.
 "Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :lndmobile. 

Tried with a basic Hello World gomobile bind and it worked as expected however building this golang app returns the errors above

https://github.com/lightningnetwork/lnd

Here are the tail of the build logs

jar: lndmobile/Callback.class
jar: lndmobile/Lndmobile$proxyCallback.class
jar: lndmobile/Lndmobile$proxySendStream.class
jar: lndmobile/Lndmobile.class
jar: lndmobile/SendStream.class
aar: jni/armeabi-v7a/libgojni.so
aar: jni/arm64-v8a/libgojni.so
aar: jni/x86/libgojni.so
aar: jni/x86_64/libgojni.so
aar: R.txt
aar: res/
jar: META-INF/MANIFEST.MF
jar: go/LoadJNI.java
jar: go/Seq.java
jar: go/Universe.java
jar: go/error.java
jar: lndmobile/Callback.java
jar: lndmobile/Lndmobile.java
jar: lndmobile/SendStream.java

@gopherbot gopherbot added this to the Unreleased milestone Feb 12, 2019

@gopherbot gopherbot added the mobile label Feb 12, 2019

@taybart

This comment has been minimized.

Copy link

commented Feb 12, 2019

Are you including more than one "class" in this build? I have had weird stuff happen when there is more than one package in the bind.

@mandelmonkey

This comment has been minimized.

Copy link
Author

commented Feb 12, 2019

Well its it no my go app that im building but yes I think it does, looking at the classes.jar file
it has the three classes
jar: lndmobile/Callback.java
jar: lndmobile/Lndmobile.java
jar: lndmobile/SendStream.java

should this be an issue?

@taybart

This comment has been minimized.

Copy link

commented Feb 12, 2019

I would try to boil it down to one and see if that fixes the issue. I think that is a problem but, isolating the issue helps to fix it.

@mandelmonkey

This comment has been minimized.

Copy link
Author

commented Feb 12, 2019

@taybart

This comment has been minimized.

Copy link

commented Feb 12, 2019

Without seeing the code I couldn't tell you, any type that you export can potentially have its own class.

@bcmills

This comment has been minimized.

Copy link
Member

commented Feb 28, 2019

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2019

What is the exact gomobile command you use? Does it work in a gradle project where you manually add the dependency? For example, you could try to use the "example" project with your .aar file instead of the hello.aar.

@mandelmonkey

This comment has been minimized.

Copy link
Author

commented Mar 1, 2019

@eliasnaur thanks for the reply, I got a new macbook and installed everything from scratch and seems to work now, so im putting it down to do my old macs environment, maybe android sdk wasnt set up correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.