【发布时间】:2022-12-27 10:36:12
【问题描述】:
When I add this line in my composable, the preview gives exception.
Code: val locationPermissionsState = rememberMultiplePermissionsState( listOf( Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION ) )
Exception message is "This preview was unable to find a CompositionLocal, and the stack trace is
java.lang.IllegalStateException: Permissions should be called in the context of an Activity at com.google.accompanist.permissions.PermissionsUtilKt.findActivity(PermissionsUtil.kt:138) at com.google.accompanist.permissions.MutableMultiplePermissionsStateKt.rememberMutablePermissionsState(MutableMultiplePermissionsState.kt:80) at com.google.accompanist.permissions.MutableMultiplePermissionsStateKt.rememberMutableMultiplePermissionsState(MutableMultiplePermissionsState.kt:48) at com.google.accompanist.permissions.MultiplePermissionsStateKt.rememberMultiplePermissionsState(MultiplePermissionsState.kt:38)
【问题讨论】:
-
The app is working fine and exactly as it should, but just the preview in Android Studio doesn't work with this thing, which makes the development a little difficult. Thanks
标签: android kotlin android-jetpack-compose