2

I am trying to make a golang package that can be included in an Android app.

So I have

  • created a golang module and built it using go bind to an aar
  • used 'new module' in Android Studio to import the aar
  • gone to project structure/dependencies/... to connect up the aar, but the aar was not listed so I could not add it.
  • the module appears to be in android/mobile; how do I tell Android Studio? Do I need to?

So

  • does anyone know what the exact command line is that I need for go bind? Assuming, say that I am trying for a module 'mobile' in a project 'hk.nurke.fred'.
  • also, how do I refer to my package in the java import statement?
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Martin Ellison
  • 1,043
  • 1
  • 13
  • 25

2 Answers2

1

Save your file in lib folder then import it by using it

compile( name : 'Name of AAR' , ext : 'aar' )

and

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
        flatDir {
            dirs 'libs'
        }
    }
}

Check it i hope you get solution

Divyanshu
  • 462
  • 6
  • 17
  • 1
    Sorry, in which files do I put the above code? What are the file paths? – Martin Ellison Jun 20 '18 at 04:17
  • @MartinEllison how did you fix it? I have the same issue, I have a large .aar file generated by gomobile, when I import it its imports but I can see it as a module however I tried a simple hello world gomobile .aar and it works ok – MandelDuck Feb 12 '19 at 12:15
0

I also got this issue today. Apparently the writer forgot to mention this in the doc Mobile#building-and-deploying-to-android.

Below is the missing step:

  1. copy "yourgolangmodule.aar" and "yourgolangmodule.jar" to "yourreactnativeproject\android\app";

  2. in "yourreactnativeproject\android\app\build.gradle" file, add below:

(how to get the clue: compare between this file in the example project from doc and the one in your project.)

enter image description here

  1. click File -> Sync Project with Gradle Files
Chenhua
  • 185
  • 2
  • 10