Note: This steps are specific to include aar file, I assume you have created a phoneGap plugin before if not go here after that follow these steps.
Step 0:
This is just a structure of how your plugin folder should look like.
pluginFolder/
build-extras.gradle
plugin.xml
aar/yourAarFile.aar
src/
android/
yourFile.gradle
myPlugin.java
Step 1:
Create plugin folder with this sub-folders: src, www and aar (if there is one).
Step 2:
Create these files in the plugin folder plugin.xml, build-extras.gradle and package.json (this is only need it if is going to be public).
Step 3:
In your plugin.xml file insert the following lines:
<platform name="android”>
<config-file target="res/xml/config.xml" parent="/*">
<feature name=“myPlugin.java” > <!—add this without the .java extension just the name —>
<param name="android-package" value=“myPlugin.java"/>
</feature>
</config-file>
<feature name=“myPlugin.java” > <!—add this without the .java extension just the name —>
<param name="android-package" value=“myPlugin.java"/>
</feature>
</config-file>
<!-- your configuration elements, references, source files, etc... —>
<framework src="src/android/yourFile.gradle" custom="true" type="gradleReference" />
<resource-file src=“aar/yourAarFile.aar" target=“aar/yourAarFile.aar" />
</platform>
Step 4:
In yourFile.gradle put the following lines:
repositories{
jcenter()
flatDir{
dirs ‘aar’
}
}
dependencies {
compile(name:'yourAarFile', ext:'aar’)
}
android { packagingOptions { exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' }
}
Step 5:
In build-extras.gradle put the following lines:
android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE
’
}
}
Step 6:
Create your java file myPlugin.java and put it in the src/android/ folder
Step 7:
Now you can use the aar file from your plugin java Class.