google/accompanist

[Permissions] Gradle update crashing permission request and the app

qsdigor opened this issue · 8 comments

Description
Updating gradle version from 8.2.1 to 8.2.2 will crash the permission request.

Here is the crash log.

 java.lang.IllegalStateException: ActivityResultLauncher cannot be null
at com.google.accompanist.permissions.MutablePermissionState.launchPermissionRequest(MutablePermissionState.kt:94)

Steps to reproduce
Start any permission request. One sample for posting notification requests.

val notificationPermissionState = rememberPermissionState(Manifest.permission.POST_NOTIFICATIONS)
notificationPermissionState.launchPermissionRequest()

Expected behavior
Launch the request and show the system dialog for the requested permission.

I haven't been able to reproduce this in the Accompanist sample app unfortunately which runs 8.2.2 so I think something else must be going on. Do you have any more info or a minimal sample project that reproduces it?

If the original site

It might be that I am launching permission requests in compose view with Timer but I did try without a timer and the same behaviour occurred.

Timer().schedule(timerTask {
    notificationPermissionState.launchPermissionRequest()
}, 1000)

Have you had a look at the Accompanist sample app and seen if there is any difference to your implementation? Without more information I don't think I can provide a fix for this

Description Updating gradle version from 8.2.1 to 8.2.2 will crash the permission request.

Here is the crash log.

 java.lang.IllegalStateException: ActivityResultLauncher cannot be null
at com.google.accompanist.permissions.MutablePermissionState.launchPermissionRequest(MutablePermissionState.kt:94)

Steps to reproduce Start any permission request. One sample for posting notification requests.

val notificationPermissionState = rememberPermissionState(Manifest.permission.POST_NOTIFICATIONS)
notificationPermissionState.launchPermissionRequest()

Expected behavior Launch the request and show the system dialog for the requested permission.

Try to ask permission in LauncheEffect block

Granted permissions ben

Launching permission request with LaunchedEffect did resolve the issue.

Launching permission request with LaunchedEffect did resolve the issue.

Then maybe you could close the issue