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.