2

I'm developing a cordova plugin and want to integrate previously developed sdk (.aar) file with it. I have tried lot of tutorials that i found from stackoverflow or elsewhere. But nothing is working. Main problem that i'm facing is ►►Not able to access the class files of sdk (.aar) file►►

Reference of my implementation : Cordova plugin development - adding aar (Answer by Niko)

Community
  • 1
  • 1

1 Answers1

1

I remember having to do a few changes to the answers found in SO to make it work, but I don't remember what was the issue with the original answers, so here's what I have in my plugin, hope it can help you.

plugin.xml :

    <platform name="android">   
             ...
             ...

            <framework src="src/android/mygraddlefile.gradle" custom="true" type="gradleReference" />
            <resource-file src="src/android/libs/myaarfile.aar" target="libs/myaarfile.aar" />
             ...
             ...
<platform>

mygraddlefile.gradle (src/android/mygraddlefile.gradle in the plugin):

repositories{    
  mavenCentral()
  flatDir{
      dirs 'libs'
   }
}

dependencies {
   compile(name:'myaarfile', ext:'aar')
}

android {
  packagingOptions {
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
  }
}

And I have the aar file in src/android/libs/myaarfile.aar in the plugin.

QuickFix
  • 11,661
  • 2
  • 38
  • 50