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: best way to import and update .aar in Android Studio #18945

beatscode opened this issue Feb 5, 2017 · 2 comments

x/mobile: best way to import and update .aar in Android Studio #18945

beatscode opened this issue Feb 5, 2017 · 2 comments


Copy link

@beatscode beatscode commented Feb 5, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.7.5 darwin/amd64

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

GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/n0/d33ctpqd2v3bzkq0g1rx4psr0000gn/T/go-build143199622=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on is best.

Wrote a small go file which exported 1 function called Justtesting(in string) string ...
Ran gomobile build -x -v -target=android com.alex/mobilelib
Went to android studio and did the following:
File > New > New Module > Import .JAR or .AAR package
File > Project Structure > app -> Dependencies -> Add Module Dependency
Add import: import mobilelib.Mobilelib;
Mobilelib.Justtesting worked after building and running.

I changed the source code of the go file and added a different exported function Getuser(a string, b string) string ...

When I tried to update the file by reimporting, Android studio stops me to say that a library with the same name already exists. So I open the directory instead and update the .aar file manually.

I notice there is a gradle plugin that seems like it might be what I'm looking for but I'm not sure how to use the build script. Android studio creates a build.grade for my module

artifacts.add("default", file('mobilelib.aar'))

I tried replacing this with the following from hello/build.gradle

plugins {
    id "" version "0.2.8"

gobind {
    /* The Go package path; must be under one of the GOPATH elements or
     a relative to the current directory (e.g. ../../hello) */
   //    pkg = ""
     pkg = "com.alex/mobilelib"
    /* GOPATH where the Go package is; check `go env` */

    /* Absolute path to the go binary */
    // GO = "/PATH/TO/GO"

    /* Optionally, set the absolute path to the gomobile binary if the
    /* gomobile binary is not located in the GOPATH's bin directory. */

What did you expect to see?

Successful build

What did you see instead?

:mobilelib:gobind FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mobilelib:gobind'.
> Cannot get property 'classpath' on null object

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


Total time: 0.427 secs
@ALTree ALTree changed the title Best way to import and update .aar in Android Studio x/mobile: best way to import and update .aar in Android Studio Feb 6, 2017
Copy link

@ALTree ALTree commented Feb 6, 2017


is this a bug report or a question about using gomobile with Android Studio?

If it's the latter, you should ask it somewhere else, since we don't use the issue tracker for questions (see the Questions wiki page; it has a list of good places for asking questions).

Copy link

@beatscode beatscode commented Feb 6, 2017

It is a bit of both.. but I can use one of those channels in the wiki

@beatscode beatscode closed this Feb 6, 2017
@golang golang locked and limited conversation to collaborators Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.