ImagePicker
ImagePicker copied to clipboard
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
I tested and it worked just fine; Even without changing the compileSdkVersion and targetsdkVersion of the library to 32.
Please try the sample app of this repo, and let me know if you have any issue on 32 or not
@Drjacky just one update - it did also work well with compile sdk 33 on an non android 13 device - but when switching to android 13 device it's not.
which device did you use for testing - Android 13? Thank in advance
Yes, Pixel 4, Android 13
last question: Did you use the sample inside this project to verfiy - If yes, I'll test this code on my devices?
Yes. please try the sample and let me know if it works or not.
@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_IMAGES for API level >= 33 inside GalleryProvider.REQUIRED_PERMISSIONS does the trick!
It's fixed on 2.3.19. Please test it and let me know if it didn't work.
Tried it on the sample app and it works fine, UNTIL I switch the dependency from the local module to the latest maven artifact:
// implementation project(':imagepicker')
implementation "com.github.Drjacky:ImagePicker:2.3.19"
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 GalleryProvider inside AS), I can see the latest changes including READ_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 found at 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 do you have any updates on this or is there any way I could help? In the meantime, maybe you can re-open the issue, since it's not actually fixed Thanks!
Thanks @astuetz! sure, the help would be to find the root of issue you've mentioned here I don't have much time this week to look at it, any help is appreciated.
@Drjacky I opened a PR here, which bumps AGP and Gradle versions and also fixes ktlint errors.
Running ./gradlew :imagepicker:build now works fine for me.
Would be great if you'd have some time to try it yourself and see if publishing works properly. Thanks!
@astuetz Could you let me know what are the versions?
- Android Studio
- echo $JAVA_HOME
- Preferences -> Build -> Gradle -> JDK
I still get this:
gradle build
Execution failed for task ':imagepicker:ktlint'. Process 'command '/Library/Java/JavaVirtualMachines/jdk-11.0.9.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
@astuetz Also, could you try this 2.3.20? But not from jitpack. from maven. Cause now I get a new error in jitpack log now: https://jitpack.io/com/github/Drjacky/ImagePicker/2.3.20/build.log
Hey, I can confirm that 2.3.20 works fine now! I guess my PR is no longer needed then?
Fixed on 2.3.20.