-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
App crashes with RecoverableSecurityException after URI resolves to content://media/<path> #679
Comments
If you're targeting android target 30, I'll downgrade for the time being. There are breaking changes in the android filesystem APIs that Cordova doesn't currently support. You can downgrade the target API via If you're targeting android target 29, then I'd either downgrade to API 28* using the preference noted above or try the
|
You're right, downgrading to The app needs to be published eventually, do you think trying out the cordova-custom-config to try to access the content URI is worth the try? (I will also try the master branch of Thanks for the help! |
With API 29, you'll need https://github.com/apache/cordova-plugin-file/pull/417/files which the So if you can add the The |
same problem here, fixed temporarily with @breautek solution, and there is no fix for Android 11... :( |
Any solution found for android 11? |
@breautek Do you know when we will have any informations about this Android 11 problem and Cordova? Is someone working on this? |
Afaik, no one is allocating time on API 30 FS problems. We need to figure out how to incorporate the MediaStore APIs for API 30. MediaStore API is significantly different than the raw file system APIs so it may be out of scope for the file plugin itself. Someone needs to analyse this problem in great detail to understand the full scope of the problem (i.e: it obviously it affects the file system usage, but does it also affect this camera plugin? file transfer plugin? media-capture plugin? etc...). Based on this ticket, the answer to each of those questions is probably a "yes". Help is wanted for this. |
Google play store will not allow publishing ionic applications with Are there any alternative solution to keep this plugin work ? Or use another Similar one. |
Could you give me the source of this information please? Thank you. |
the last Time i published , the Ionic APK to play store , I Got this warning :
In my Case , I commented the code line that crash the Plugin in a fork branch (interstellerS@884ff37 ) , Then both the image capture and save to gallery worked just Fine! I wonder if the entrerpise version of this plugin has a fix for this . |
Workaround for issue described here: apache#679
From what I can tell, taking a picture with this plugin might always add the picture to the phones gallery (=MediaStore), even if The deletion of files in the MediaStore changed with the Scoped Storage changes introduced in SDK 29. In SDK 29 this permission may be requested via the RecoverableSecurityException. Starting from SDK 30, a delete request can be created. You can find a simple implementation for this here: https://github.com/jkorrek/cordova-plugin-camera/blob/sdk-30-deletion/src/android/CameraLauncher.java#L1267 As I am not sure if I want to bother our users with this deletion request, I also added a flag to explicitly activate this behaviour. For Android 10 / SDK 29 the confirmation request show to the user will look like this: I wasn't able to test this for Android 11 / SDK 30 yet. |
Hi, Im having this issue with a Lenovo tab. Using the requestLegacyFileStorage flag is not an option as targetting api level 30 is mandatory. And as it's working well on most device, I believe thats i do not really need to upgrade the plugin version. Somebody have a workaround ? Its seems to crash on the checkForDuplicate function in cameraLuncher.java when trying to delete the image using the uri... im quite hopeless as im starting to change the java file for debugging .... Thx in advance Edit : Copy of my logcat :
|
Any update on this? I see there is a PR 781 After updating to the latest version of the camera plugin, our Android Crashes and ANR in the Play Developer Console, shows a number of users experiencing this issue.
|
This implementation just swallows the Exception, because we do not want to bother our users with a permission question for each photo we take. For more information and other approaches refer to apache#679
This implementation just swallows the Exception, because we do not want to bother our users with a permission question for each photo we take. For more information and other approaches refer to apache#679
This implementation just swallows the Exception, because we do not want to bother our users with a permission question for each photo we take. For more information and other approaches refer to apache#679
@breautek anything we can do to push the PR along? We are seeing a bit of crashes of users with non default camera apps. |
@breautek We have a user experiencing these crashes, and gave them a .apk of our app with the code in proposed 6.01 patch or rather to be precise we installed this version of the plugin dongourdet@fa95703 This fixed the issue for our user.. Is there a timeline for getting this fix out in the wild in the official plugin? |
I took the fork commit from dongourdet@fa95703 and rebased it on top of the main repo's current master (2023-06-08 23642f0 ) and built on an Android 12 before and after and this fix also looks like it solves the problem for our Android device as well. I see https://github.com/apache/cordova-plugin-camera/milestone/4 Great plugin, great work identifying the issue! |
I did the same as @PabbleDabble and sent our app to a customer who experiences the crashing issue on their tablet. It resolved the crash, but they state that every time they take a photo it asks for permission to modify the picture. I'm still waiting to hear back from them on the exact message they see. Is anyone experiencing this? I don't see what could make Android ask for permission every single time a photo is taken. Thanks! |
@JeffBerman I only did a quick test so this could be happening, not sure. We just send build to QA, I'll ask our Android 12 user to test again and update asap. |
Just a little update: I'm not sure how relevant this is, but our customer says the patched camera plugin works with their Galaxy tablet but not their Lenovo ones. The Galaxy uses the com.sec.android.app.camera camera package, while the Lenovo uses the com.mediatek.camera package. I'm not too familiar with how Android works, but it sounds like there's some incompatibility between the Mediatek camera software and either Android 11 or this plugin, that causes it to ask for permission with every photo they take. |
@JeffBerman The person who has the Android 12 still hasn't tested, but now Android 13 is a whole new issue for us... Here's the comment path I've used that seems to work on 13 (still other related issues with cordoav-plugin-file and copying file from gallery) I'm PRAYING that forks fixed the Android 12 issue as well, so I can just used that and not need to merge in DonGourdet's changes as well. I will update if I test the fork for Android 13 on an Android 12 device with my results. |
Update to my above comment: I tested on Android 12 with JUST the fork for Android 13 here (hoping it was the same issue), but it was not apparently. I then combined both the Android 13 fork here and the Android 12 fork (here) and rebuilt and tested on both Android 12 and 13. I had to update cordova-plugin-file from 6->8 which required me to update cordova-android as well, and not with my customer double fork, it looks like I have both working. I got the custom double for by doing the following:
I'll document locally, and then when either / both of these fixes go through, I can revert back to installing from the plugin's page. |
Yes. This is happening to me as well. It's better than crashing. Maybe worth pinging the fork author? I don't know if that's correct etiquette here tho. |
I don't think the permission grant thing addressable. The removal of the This means if you're modifying a file that is owned by another app, you must obtain permission to write to that file. This permission grant is a temporarily grant and is only valid for that specific file. So if you're trying to modify multiple files owned by another app, then you must be granted permission for each file. I believe the permission grant is valid for as long as your android activity lives. Whenever your app's activity gets killed, any permission grants to uris is revoked if I recall correctly. |
Hi everyone, I am having the same problem here, happening on different devices, Samsung - Thanks! |
Any update on this? |
@breautek In our customers' case, they are the ones taking the photo. Our mobile app uses the camera plugin to take a photo, then the same app sends the photo to a server. Customers are complaining that every time they snap a photo it asks for permission. Does this scenario sound consistent with your understanding of how Android now handles these things? |
Hi @PabbleDabble Would you consider creating a fork or a pull request with your changes on the original cordova-plugin-camera repository? This could really help others in the community. Thanks for your contribution! |
https://github.com/PabbleDabble/cordova-plugin-camera Here's the steps I took after forking master from this main
For the record, I think the A12 cherry-pick is still probably not perfect as it asks for permission to delete the temp file after capture each time which is not great (but better than a crash). Here's where I found comments / notes to why I did what I did... |
Thank you very much. It's almost the same as the changes I implemented. But I still don't understand why, even though I work with the image as a blob (last option), it keeps trying to access content://media/external/images/media/ and generating android.app.RecoverableSecurityException. On Android 10 devices, the application crashes; however, on version 13, it generates the error but doesn't close the app. |
This was originally opened for API 30 which should have already been fixed in v6 of the plugin, but the issue would re-appear for API 33 devices, which will be resolved by #844 |
Can anyone confirm if this is fixed in 7.0.0? Noticed that this error was occurring for some users and I was able to reproduce it using the Timestamp even when using 7.0.0. Perhaps I'm doing something else wrong. |
We are using 7.0.0. In the Google Play Store logs we two variations of this error: And: I can't reproduce on our devices, but our customers can according to the crash logs. |
Bug Report
Problem
App crashes when using Timestamp app to take a picture.
What is expected to happen?
App should inform that the URI is not accessible by app, not crash.
I have tried converting the "content://media/" into a "file://" without succes.
I verified all permissions and the function works fine when using device's camera.
What does actually happen?
App is killed by OS...
Log from
adb logcat
Information
Command or Code
Environment, Platform, Device
Bug occurs on different Android 9 devices.
Version information
ionic info
Ionic:
Ionic CLI : 5.4.9 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 5.0.0
@angular-devkit/build-angular : 0.803.24
@angular-devkit/schematics : 8.3.25
@angular/cli : 8.3.25
@ionic/angular-toolkit : 2.1.2
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 7.1.0, browser 6.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 15 other plugins)
Utility:
cordova-res : not installed
native-run : 1.2.1 (update available: 1.2.2)
System:
NodeJS : v14.2.0 (/home/gerardo/.nvm/versions/node/v14.2.0/bin/node)
npm : 6.14.4
OS : Linux 5.4
Checklist
I'm trying to retrieve plugin callback as mentioned in :
https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#upgrading (Last section)
The text was updated successfully, but these errors were encountered: