ImagePicker: Photo picker does not open with compile sdk 33 (Android 13)
Describe the bug App picker does not open with compile sdk 33 after permission handling Tested with version 32 (Android 12) and it works
Sample code:
` val launcher = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) { if (it.resultCode == Activity.RESULT_OK) { onAvatarChanged(it.data?.data!!) } }
AvatarImageUI(
initials = firstName?.take(2) ?: "",
avatarUri = avatarUrl,
fontSize = 50.sp,
canEdit = canEditAvatar,
onEditClick = {
ImagePicker.with(activity)
.maxResultSize(maxAvatarSize, maxAvatarSize)
.cropSquare()
.provider(ImageProvider.BOTH)
.setOutputFormat(
if (Utils.isAtleastR()) Bitmap.CompressFormat.WEBP_LOSSY else Bitmap.CompressFormat.WEBP
)
.createIntentFromDialog { launcher.launch(it) }
},
size = Constants.Size.AVATAR_BIG,
)`
Looking forward to you comments. Thank you in advance
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (8 by maintainers)
Hey, I can confirm that 2.3.20 works fine now! I guess my PR is no longer needed then?
Tried it on the sample app and it works fine, UNTIL I switch the dependency from the local module to the latest maven artifact:
By doing so, the sample app again tells me that the storage permission is required.
If I look at the downloaded apk sources (or try to look at
GalleryProviderinside AS), I can see the latest changes includingREAD_MEDIA_IMAGES. But as soon as I decompile the actual aar, all the latest changes are missing.Looking at the report on jitpack, it also says
ERROR: No build artifacts foundat the very end, so maybe something’s wrong with publishing?Just to be safe I also tried clearing all my caches, but the problem still persists.
@Drjacky @fairEnough83 is right, this requires a change for Android 13: https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions
Seems like simply using
Manifest.permission.READ_MEDIA_IMAGESfor API level >= 33 insideGalleryProvider.REQUIRED_PERMISSIONSdoes the trick!