I came across a Cheese Factory article (google it because I cannot post more than 2 links with my reputation) which explains how to handle the new permissions system for Android Marshmallow. In the article, he references the Permissionsdispatcher library which aims to reduce boilerplate code. So I downloaded the library demo from GitHub but I get an error which says MainActivityPermissionsDispatcher cannot be resolved. From what I can understand, this class should be generated. How can I generate it to remove the error ?
MainActivity.java
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
// delegate the permission handling to generated method
// MainActivityPermissionsDispatcher cannot be resolved
MainActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
}
I'm a developer. Thanks for your using.
Like described here https://github.com/hotchemi/PermissionsDispatcher#must
You will have to add the @RuntimePermissions
Annotation to your activity and a @NeedsPermission
Annotation to a method at least.
In your build.gradle add the following:
buildscript {
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
}
}
apply plugin: 'android-apt'
dependencies {
compile 'com.github.hotchemi:permissionsdispatcher:1.2.1@aar'
apt 'com.github.hotchemi:permissionsdispatcher-processor:1.2.1'
}
The android-apt plugin will take care of the annotation processing. After building the project you should be able to use the generated class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With