Skip to content
Branch: master
Go to file

Latest commit


Failed to load latest commit information.
Latest commit message
Commit time

Android Permissions Gradle Plugin (2.0.1)


Since Android Marshmallow, developers have to request permissions the Android SDK considers dangerous, aka Dangerous Permissions.

This plugin generates a class to help with that task. It parses the Android Manifest on build and generates a helper class with the list of the Dangerous Permissions plus a few utility methods.

Generated Code

If your manifest contains those three permissions:

<manifest package="" xmlns:android="">
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

The plugin will generate this helper class named PermissionsHelper:

public class PermissionsHelper {
    public static final String [] REQUIRED_PERMISSIONS = {

The generated class contains a static String [] of all the dangerous permissions from the manifest. Note that you can see here only two declared permissions as the permission android.permission.INTERNET is a not a dangerous permission.


In your root build.gradle add the plugin, published in jCenter:

buildscript {
    repositories {
    dependencies {
        classpath ''

In every Android Application or Library module, apply the plugin:

apply plugin: ''


The generated class helper is named by default PermissionsHelper and the default package name depends on variant.applicationId. If variant.applicationId is for instance, the package name will be


You can change the package name and the class name to suit your needs. For instance if you prefer the 'utils' convention:

android {
permissions {
    helperPackage android.defaultConfig.applicationId + ".util"
    helperClassName "PermissionsUtils"

Utility Methods

The class contains utility methods to ease the work with the System Permissions API.

public static boolean granted(Context context) {}
public static boolean granted(Context context, String... permissions){}
public static String [] filterGranted(Context context) {}
public static String [] filterGranted(Context context, String... permissions){}
public static String [] filterNotGranted(Context context) {}
public static String [] filterNotGranted(Context context, String... permissions) {}

Change log

  • 2.0.1 Bug fix where the parameter "helperPackage" was not used as import
  • 2.0.0 Entirely rewritten in Kotlin, yay!
  • 1.1.0 Compatibility fix for the Android Gradle Plugin 3.0.0-alpha5
  • 1.0.7 Compile plugin with JDK 6 to avoid a compatibility error
  • 1.0.6 First release

Next steps

  • Get rid of templates for the code generation and use JavaPoet
  • Add an option to generate a Kotlin helper class via KotlinPoet instead of the Java helper class


This plugin is available under the Apache License, Version 2.0.

(c) All rights reserved Alexander Gherschon


Plugin generating a helper class to deal with the new Permissions System in Marshmallow




You can’t perform that action at this time.