android - Cordova plugin development - adding aar -


i new cordova plugin development stuff. want write plugin able open new android activty , showing advertisement.

so followed simple tutorial here. works , expected.

next step include android studio gradle project plugin.

my first try: adding gradle project subfolder of cordova plugin , adding following line plugin.xml file:

<framework src="libs/broper/build.gradle" custom="true" type="gradlereference" /> 

also tried:

<framework src="libs/broper/app/build.gradle" custom="true" type="gradlereference" /> 

the graddle files recognised cordova. don't work. can't import classes of android studio project plugin java files.

then better solution (i thought so) add aar instead. there don't have clue add aar in cordova plugin.

so, question is: how add android atudio aroject (or library) cordova plugin right way?

here's i've done use gradle reference cordova plugin, think might you.

global structure :

pluginfolder/   build-extras.gradle   plugin.xml   yourdircontainingyouraar/   src/     android/       yourfile.gradle       myplugin.java 

put library, foo.aar, in yourdircontainingyouraar directory (create if needed)

  • in plugin.xml file :

    <platform name="android">     <!-- configuration elements, references, source files, etc... -->      <framework src="src/android/yourfile.gradle" custom="true" type="gradlereference" />      <resource-file src="yourdircontainingyouraar/foo.aar" target="libs/foo.aar" /> </platform> 
  • in gradle file yourfile.gradle :

    repositories{       jcenter()   flatdir {       dirs 'libs'    } }  dependencies {    compile(name:'foo', ext:'aar') }  android {   packagingoptions {     exclude 'meta-inf/notice'     exclude 'meta-inf/license'   } } 
  • in root folder of plugin (same level plugin.xml ) create build-extras.gradle. if needed, add or remove minsdkversion , targetsdkversion according project needs :

    android {     defaultconfig {         minsdkversion 16         targetsdkversion 22     }     packagingoptions {        exclude 'meta-inf/notice'        exclude 'meta-inf/license'    } } 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -