permissions-dispatcher / PermissionsDispatcher

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

Conflict with Dagger Hilt #704

Closed mohammedelnady closed 3 years ago

mohammedelnady commented 3 years ago

Hi there, i am using your best library alongside the dagger hilt DI library, But I faced this compile-time issue when i uses them together

somepath/di/AssistedInjectModule.java:8: error: cannot find symbol @dagger.Module(includes = {AssistedInject_AssistedInjectModule.class})

@RuntimePermissions
abstract class PermissionsActivity :LocaleAwareCompatActivity() {
 @NeedsPermission(Manifest.permission.CAMERA)
    fun showCamera() {

    }

    @OnPermissionDenied(Manifest.permission.CAMERA)
    fun onCameraDenied() {
        Toast.makeText(this, R.string.permission_camera_denied, Toast.LENGTH_SHORT).show()
    }

    @OnShowRationale(Manifest.permission.CAMERA)
    fun showRationaleForCamera(request: PermissionRequest) {
        showRationaleDialog(R.string.permission_camera_rationale, request)
    }

    @OnNeverAskAgain(Manifest.permission.CAMERA)
    fun onCameraNeverAskAgain() {
        Toast.makeText(this, R.string.permission_camera_never_ask_again, Toast.LENGTH_SHORT).show()
    }

    @NeedsPermission(Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS)
    fun showContacts() {

    }

    @OnPermissionDenied(Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS)
    fun onContactsDenied() {
        Toast.makeText(this, R.string.permission_contacts_denied, Toast.LENGTH_SHORT).show()
    }

    @OnShowRationale(Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS)
    fun showRationaleForContacts(request: PermissionRequest) {
        showRationaleDialog(R.string.permission_contacts_rationale, request)
    }

    @OnNeverAskAgain(Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS)
    fun onContactsNeverAskAgain() {
        Toast.makeText(this, R.string.permission_contacts_never_ask_again, Toast.LENGTH_SHORT).show()
    }

    private fun showRationaleDialog(@StringRes messageResId: Int, request: PermissionRequest) {
        AlertDialog.Builder(this)
            .setPositiveButton(R.string.allow) { _, _ -> request.proceed() }
            .setNegativeButton(R.string.deny) { _, _ -> request.cancel() }
            .setCancelable(false)
            .setMessage(messageResId)
            .show()
    }
}
abstract class DataBindingActivity : PermissionsActivity() {

    protected inline fun <reified T : ViewDataBinding> binding(
        @LayoutRes resId: Int
    ): Lazy<T> = lazy { DataBindingUtil.setContentView<T>(this, resId) }
}

### the issue appears here

@RuntimePermissions
@AndroidEntryPoint
class SplashActivity : DataBindingActivity(),SplashManipulation {
}
hotchemi commented 3 years ago

Hi, Would you mind elaborating the issue more? Honestly speaking, we've got several reports in the past but none of those was due to our lib...as you know kapt is one of the trickiest parts in Kotlin and that's why we've developed https://github.com/permissions-dispatcher/PermissionsDispatcher/tree/master/ktx 😅

hotchemi commented 3 years ago

@mohammedelnady let us close the issue, we'll reopen the issue if you're still struggling with the issue 🙏