Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 13 Image picker not opening - hasReadPermission function promise always return as false #264

Open
3 tasks done
hiteshbasware opened this issue Jul 21, 2023 · 16 comments

Comments

@hiteshbasware
Copy link

hiteshbasware commented Jul 21, 2023

Bug Report

Problem

hasReadPermission function promise always return as false, resulting in Image picker not opening the selection window with the check implementation.

What is expected to happen?

hasReadPermission should only return false if permission is not given for images access.

What does actually happen?

READ_EXTERNAL_STORAGE android permission is now divided into 3 different media sub-sections in new Android API version 13 i.e READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, READ_MEDIA_AUDIO. So App can not find access to required permission returns promise as false.

Information

hasReadPermission & requestReadPermission function in ImagePicker.java is trying to look for old permission on new Android which is not available, hence returns false always.

Command or Code

this.imagePicker.hasReadPermission()
.then((result) => {
// result is always false:boolean

Environment, Platform, Device

Any Android Device with Android 13 OS

Version information

Cordova: 12, node: 16.14.1
Operating System: windows 10, Android Studio: Android Studio Bumblebee 2012.1.1

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@beard7
Copy link

beard7 commented Aug 21, 2023

This is a pretty big problem, given that Google won't accept updates to apps that don't target API level 33 after August 31.

Any suggestions for a fix?

@hiteshbasware
Copy link
Author

This is fixed in https://github.com/VerianMobile/ImagePicker

Its a temporary fix but it works for now.

@beard7
Copy link

beard7 commented Aug 22, 2023

@hiteshbasware Thanks, but that gives me an error during build:

Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
    class com.synconset.MultiImageChooserActivity, unresolved supertypes: AppCompatActivity

@hiteshbasware
Copy link
Author

hiteshbasware commented Aug 22, 2023

@hiteshbasware Thanks, but that gives me an error during build:

Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
    class com.synconset.MultiImageChooserActivity, unresolved supertypes: AppCompatActivity

I think your project is not using androidX that is the reason.
src/android/com/synconset/ImagePicker/ImagePicker.java in core plugin is now using androidx.core.app.ActivityCompat

If you want you can create your own fok and use old libraries. Preferably if you are using API level 28 or higher you should use androidX.

For cordova you have to add following line in config.xml
<preference name="AndroidXEnabled" value="true" />

or you can use - https://github.com/dpa99c/cordova-plugin-androidx-adapter

@mfschieber
Copy link

Hey, is there any update on this issue ? Can we have a approximate deadline for the fix please ? It's a big issue for our clients that are using android 13 and can't import any photo anymore

@beard7
Copy link

beard7 commented Aug 24, 2023

I know some people don't like using forks, but I've found this one to be excellent:
spoonconsulting/cordova-plugin-telerik-imagepicker

@tomaszpaczesny
Copy link

Since targeting Android 13 for library like this must use READ_MEDIA_IMAGES permission instead of READ_EXTERNAL_STORAGE which is now deprecated.
This is solved in this PR I opened. Feel free to use our fork or create your own if this won't get merged soon.

#265

@lechuit
Copy link

lechuit commented Sep 4, 2023

This is fixed in https://github.com/VerianMobile/ImagePicker

Its a temporary fix but it works for now.

work for me! thx

@Cap-7
Copy link

Cap-7 commented Sep 17, 2023

Tried this fork, but getting error on building the app,
error: cannot find symbol new String[] {Manifest.permission.READ_MEDIA_IMAGES},
symbol variable READ_MEDIA_IMAGES
location: class permission.

I am having an ionic app, and i have added
in the android manifest.xml

And my config.xml is having android TargetSdkversion 33.

Please help through it, as I have a production planned for October. And am new to mobile development

@lechuit
Copy link

lechuit commented Sep 19, 2023

Tried this fork, but getting error on building the app, error: cannot find symbol new String[] {Manifest.permission.READ_MEDIA_IMAGES}, symbol variable READ_MEDIA_IMAGES location: class permission.

I am having an ionic app, and i have added in the android manifest.xml

And my config.xml is having android TargetSdkversion 33.

Please help through it, as I have a production planned for October. And am new to mobile development

Check Java version, you need Java 11 for sdk33

@Cap-7
Copy link

Cap-7 commented Sep 28, 2023

@lechuit

Tried this fork, but getting error on building the app, error: cannot find symbol new String[] {Manifest.permission.READ_MEDIA_IMAGES}, symbol variable READ_MEDIA_IMAGES location: class permission.
I am having an ionic app, and i have added in the android manifest.xml
And my config.xml is having android TargetSdkversion 33.
Please help through it, as I have a production planned for October. And am new to mobile development

Check Java version, you need Java 11 for sdk33

When I ran java -version

These are the details I am getting.
openjdk version "1.8.0_332"
openJDK Runtime Environment (Temurin) (build 1.8.0_332-b09)
OpenJDK 64-Bit Server VM (Temurin)(build 25.332-b09, mixed mode)

@Mr-Anonymous
Copy link

This is not working for me too. I also tried the Verian Mobile and the Spoon consulting forks mentioned above and they don't work either. I also tried updating my Cordova Android to 12.0.0, Java to 17, Gradle and build tools and still nothing works. When clicked, the plugin does not respond and it does not give any error message either. I have tried other plugins too and they all have the same issue once the target sdk has been changed to 33 which is the requirement now from Google.

Can someone share if you found a working solution please? This is a big problem.

@Cap-7
Copy link

Cap-7 commented Oct 29, 2023

This is not working for me too. I also tried the Verian Mobile and the Spoon consulting forks mentioned above and they don't work either. I also tried updating my Cordova Android to 12.0.0, Java to 17, Gradle and build tools and still nothing works. When clicked, the plugin does not respond and it does not give any error message either. I have tried other plugins too and they all have the same issue once the target sdk has been changed to 33 which is the requirement now from Google.

Can someone share if you found a working solution please? This is a big problem.

Hey for me, verian fork worked, I just did a Java 11 update.
Then things working for me.
Just make sure, if your using diagnostic plugin by any chance that also requires an updated version.
My cordova android is 10.0.0

@Mr-Anonymous
Copy link

Thank you @Cap-7 for your response. I don't have a diagnostic plugin. After I updated to Android 12, I needed to update couple of plugins such as File and File transfer. Here is my plugins list. Is there anything you feel might cause an issue with this?

@spoonconsulting/cordova-plugin-telerik-imagepicker 2.0.4 "ImagePicker"
cordova-plugin-add-swift-support 2.0.2 "AddSwiftSupport"
cordova-plugin-android-permissions 1.0.2 "Permissions"
cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter"
cordova-plugin-androidx 3.0.0 "cordova-plugin-androidx"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-file-opener2 2.2.1 "File Opener2"
cordova-plugin-file-transfer 2.0.0 "File Transfer"
cordova-plugin-file 8.0.0 "File"
cordova-plugin-headercolor 1.0 "HeaderColor"
cordova-plugin-ignore-lint-translation 0.0.1 "cordova-plugin-ignore-lint-translation"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ios-camera-permissions 1.2.0 "iOS Permissions"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-splashscreen 6.0.0 "Splashscreen"
cordova-plugin-statusbar 2.4.4-dev "StatusBar"
cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
ionic-plugin-deeplinks 1.0.15 "Ionic Deeplink Plugin"
onesignal-cordova-plugin 3.3.1 "OneSignal Push Notifications"

Thanks again for helping out.

@Cap-7
Copy link

Cap-7 commented Oct 29, 2023

Thank you @Cap-7 for your response. I don't have a diagnostic plugin. After I updated to Android 12, I needed to update couple of plugins such as File and File transfer. Here is my plugins list. Is there anything you feel might cause an issue with this?

@spoonconsulting/cordova-plugin-telerik-imagepicker 2.0.4 "ImagePicker"
cordova-plugin-add-swift-support 2.0.2 "AddSwiftSupport"
cordova-plugin-android-permissions 1.0.2 "Permissions"
cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter"
cordova-plugin-androidx 3.0.0 "cordova-plugin-androidx"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-file-opener2 2.2.1 "File Opener2"
cordova-plugin-file-transfer 2.0.0 "File Transfer"
cordova-plugin-file 8.0.0 "File"
cordova-plugin-headercolor 1.0 "HeaderColor"
cordova-plugin-ignore-lint-translation 0.0.1 "cordova-plugin-ignore-lint-translation"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ios-camera-permissions 1.2.0 "iOS Permissions"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-splashscreen 6.0.0 "Splashscreen"
cordova-plugin-statusbar 2.4.4-dev "StatusBar"
cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
ionic-plugin-deeplinks 1.0.15 "Ionic Deeplink Plugin"
onesignal-cordova-plugin 3.3.1 "OneSignal Push Notifications"

Thanks again for helping out.

My story was different, in my case I kept my app on android 10.0.0 , so things didn't break as much.
Can you post your exact issue?
Is it something like app is building but image picker not responding?

@Mr-Anonymous
Copy link

I was able to finally get this working. What worked for me was in the end change a few things in my environment and after a lot of combination trials, the following set-up works for my project:

  1. I had to change my Java version from 17 to 11.

  2. Use Node v18.18.2.

  3. Use Cordova Android 12.0.0 (Android 10 works too).

  4. Use the cordova cli to build instead of using Android Studio.

Now with the above changes, I am finally able to get the plugin to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants