My first Gradle Plugin, Android Permissions Gradle Plugin was just deployed into jCenter. Yay!

Developing this was a great experience. I use gradle heavily as any other developer as the main project I’m working on has lots of flavors. But the need never arose for a Gradle Plugin until recently, when I wanted to compile the project with the latest Android version, 23, aka marshmallow.

What is the issue with the new Android Permissions System in Marshmallow? Nothing, it’s a great feature. It was long time due in my opinion. As a developer you have to request on runtime the Dangerous Permissions you have declared in your Android Manifest. But there is no API (that I’m aware of!) to request from Android the list of your declared Dangerous Permissions.

So this plugin gives you just that: a static list of your declared Dangerous Permissions plus some useful static methods, per variant.

To build a gradle plugin, you will need some documentation:

What opened my eyes on how to get this done are the Android Dev Summit 2015 talks which are GREAT. If you didn’t watch them already, I strongly suggest you do.

In one of the talks, Android Build System, the Android Tools Team talks about this function:

variant.registerJavaGeneratingTask(task, outputFolder)

Exactly what I needed! From there, parsing the manifest to generating the helper class was just a matter of time & tears.

I hope this plugin will be helpful to more people than just myself, and will be glad to get your feedback!