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 10 Feb. update not reading images #188

Open
rklus16 opened this issue Feb 13, 2020 · 10 comments
Open

Android 10 Feb. update not reading images #188

rklus16 opened this issue Feb 13, 2020 · 10 comments

Comments

@rklus16
Copy link

rklus16 commented Feb 13, 2020

When trying to select a photo from the image picker getPictures error function returns "The image file could not be opened." Tested on device and emulator. Same result with a file_uri or base64.

Plugin works correctly on Android 9.

@deliverymanager
Copy link

Did you find any solution on this?

@rklus16
Copy link
Author

rklus16 commented Feb 26, 2020

No, decided to switch back to the camera plugin which only allows selecting one image at a time but it works. Still use this for iOS though until a fix for Android is available.

@deliverymanager
Copy link

deliverymanager commented Feb 26, 2020

Looks like this happens to other plugins too.
The reason is that the Android 10 has a new way to read the storage.
For now you can use <preference name="android-targetSdkVersion" value="28" />
in order to target older version that uses the older file system.

This way I solved it for now ...

@rklus16
Copy link
Author

rklus16 commented Feb 26, 2020

@deliverymanager thanks for the heads up. I didn't even think about trying that. Reason being is this plugin seemed to be working with Android 10 pre-February patch update. I'll give this a shot.

@gaurav-chandra
Copy link

This is happening with me also. <preference name="android-targetSdkVersion" value="28" /> solves this but not api level 29. I am on Android 10 pixel phone.

@gaurav-chandra
Copy link

Add the following in config under android platform:

        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:requestLegacyExternalStorage="true" /><!--Needed for image picker-->
        </edit-config>

and use target sdk 29. Then build. Ensure that the build-tools need to be version >=30. If using 30.0.0-rc-2, the app will not build.

https://stackoverflow.com/questions/58430070/android-apiv29-filenotfoundexception-eacces-permission-denied

@arihantdaga
Copy link

arihantdaga commented Jul 26, 2020

I tried gaurav's suggestions, but i kept getting build errors.
I didn't know how to port his plugin properly, so I made a clone for it to work with android storage access framework, keeping same API.
https://github.com/arihantdaga/cordova-plugin-imagepicker

Later, i'll try to do rearrange the code and fit in this repo itself, and based on the platform version it can chose which way to use to access images.

MayankLogiciel referenced this issue in MayankLogiciel/cordova-plugin-image-picker Jul 28, 2020
For Android 10 to support target sdk 29
@coddark
Copy link

coddark commented Aug 11, 2020

Add the following in config under android platform:

        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:requestLegacyExternalStorage="true" /><!--Needed for image picker-->
        </edit-config>

and use target sdk 29. Then build. Ensure that the build-tools need to be version >=30. If using 30.0.0-rc-2, the app will not build.

https://stackoverflow.com/questions/58430070/android-apiv29-filenotfoundexception-eacces-permission-denied

@gaurav-chandra I tried your solution, but it does not work in some devices.

@scr34m
Copy link

scr34m commented Sep 10, 2020

See #220 about this issue to be fixed, with out any work arounds.

@saviour2008
Copy link

saviour2008 commented Oct 15, 2020

I install version 2.3.3 in order to resolve #216 ,but if I add <application android:requestLegacyExternalStorage="true" /> in , it will throw the error #212 , so there is no <application android:requestLegacyExternalStorage="true" /> in config.xml, but now there is not reading images in Android 10, so should I install which version? @scr34m

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