permissions-dispatcher / PermissionsDispatcher

A declarative API to handle Android runtime permissions.
https://github.com/permissions-dispatcher/PermissionsDispatcher
Apache License 2.0
11.21k stars 1.44k forks source link

Build Errors :Cannot access RuntimePermissions #676

Closed woaihuangfan closed 4 years ago

woaihuangfan commented 4 years ago

FAQs

Hi ~ I use the version 4.1.0 with andoridx in my project . I rebuild the project but error happened. reminds me " Compilation failed; see the compiler error output for details." . Then I run with the cmd "gradlew compileDebugSource --stacktrace -info" in android stuidio terminal,
I see the error info " Error : Cannot access RuntimePermissions, cannot find permissions.dispatcher.RuntimePermissions class file", so I can't generate xxxxPermissionsDispatcher by this way. But when I use the android studio plugin I get the xxxxPermissionsDispatcher and still cannot build, faced the same error. I spend lot's of time on this problem, has anyone ever had a similar problem? Help ! Thank you very much!

The build.gradle:

    implementation 'com.github.permissions-dispatcher.PermissionsDispatcher:permissionsdispatcher:4.1.0'
    annotationProcessor 'com.github.permissions-dispatcher.PermissionsDispatcher:permissionsdispatcher-processor:4.1.0'

The java content:

@RuntimePermissions
public abstract class PermissionCheckerDelegate extends BaseDelegate {

    @NeedsPermission(Manifest.permission.CAMERA)
    void startCamera(){
        LatteCamera.start(this);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        PermissionCheckerDelegatePermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
    }

}

tips: The BaseDelegate extends androidx.fragment.app.Fragment

sorry to bother.

woaihuangfan commented 4 years ago

well , I figured this out by changing "implementation" to "api", the build errors disappeared.

api 'com.github.permissions-dispatcher.PermissionsDispatcher:permissionsdispatcher:4.1.0'

hope this can be helpful if someone has the same problem.

This issue will be closed.