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
Closed
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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@mandelmonkey
Copy link

mandelmonkey 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 Android, iOS, and x/mobile label Feb 12, 2019
@taybart
Copy link

taybart 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
Copy link
Author

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
Copy link

taybart 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
Copy link
Author

mandelmonkey commented Feb 12, 2019 via email

@taybart
Copy link

taybart 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
Copy link
Contributor

bcmills commented Feb 28, 2019

CC @eliasnaur @hyangah

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 28, 2019
@eliasnaur
Copy link
Contributor

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.

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 28, 2019
@mandelmonkey
Copy link
Author

@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

@golang golang locked and limited conversation to collaborators Feb 29, 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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants