Search code examples
androidandroid-studiogoaargomobile

Cannot import AAR from golang into my app (tried previous answers but they do not work)


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?

Solution

  • 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