google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.42k stars 597 forks source link

[Permissions] Gradle update crashing permission request and the app #1746

Closed qsdigor closed 8 months ago

qsdigor commented 8 months ago

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.

bentrengrove commented 8 months ago

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?

Mwhite69 commented 8 months ago

If the original site

qsdigor commented 8 months ago

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)
bentrengrove commented 8 months ago

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

PalankiBharat commented 8 months ago

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

Mwhite69 commented 8 months ago

Granted permissions ben

qsdigor commented 8 months ago

Launching permission request with LaunchedEffect did resolve the issue.

PalankiBharat commented 8 months ago

Launching permission request with LaunchedEffect did resolve the issue.

Then maybe you could close the issue