Closed lanadedstudio closed 3 weeks ago
I have same problem here for version 4.2.
@charlieshin @lanadedstudio can you both try with the latest camera plugin release?
I have just released a few hours ago version 5.0.0.
You should be able to use the latest just by removing and readding.
cordova plugin rm cordova-plugin-camera
cordova plugin add cordova-plugin-camera
Sorry, I should also note that the latest release also required Cordova-Android platform >= 9.0.0
.
I am having a similar issue where when I take a picture with the new version 5.0.0
on Cordova 10 it just returns a null
Is this reproducible in a new, plain Cordova app? A minimal reproduction repository would really help to debug and later fix this issue. More information on how to create one: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md
Just checked with a fresh cordova app, also fails there. If I have editing enabled, it says editing isn't allowed, and if I disable it it just sends out a Error capturing image.
in the console.
Can you test with FILE_URI
instead of DATA_URL
destination types?
In my experience, DATA_URL
can cause memory issues and results in crashes on some devices, because representing high resolution images in a bae64 encoded string is rather inefficient. This is also noted in the docs.
Alternatively, you could also try resizing the image using the targetWidth
and targetHeight
camera options.
I am having a similar issue where when I take a picture with the new version 5.0.0 on Cordova 10 it just returns a null ... Just checked with a fresh cordova app, also fails there. If I have editing enabled, it says editing isn't allowed, and if I disable it it just sends out a Error capturing image. in the console.
I'm not convinced this is the same issue as the OP described. You're describing an error case, where the OP is describing a crash (which I may be falsely interpreting that the app is closing unexpectedly). You may want to create a new issue so that we can track the issue you described independently.
@charlieshin @lanadedstudio can you both try with the latest camera plugin release?
I have just released a few hours ago version 5.0.0.
You should be able to use the latest just by removing and readding.
cordova plugin rm cordova-plugin-camera cordova plugin add cordova-plugin-camera
Sorry, I should also note that the latest release also required Cordova-Android platform
>= 9.0.0
.
I will test with the new version! TKS
I'm using the android version 8.1.0 because i'm building my app with Monaca and them requires this version... but i will try update android too
@breautek We are already using FILE_URI. I will create a new repo to track these issues differently
Moved my issue discussion over to as that is the right issue as it's the exact same as me. https://github.com/apache/cordova-plugin-camera/issues/611
@lanadedstudio is this issue still happening with the latest released version? If not, feel free to close this issue.
Yes, this continues to happen on some devices. Even with the updated plugin and using FILE_URI instead of DATA_URL.
Are you able to provide a stacktrace of the crashes?
After updating the plugin, the photos with the front camera are working, but the photos with the back camera still close the application. I removed the option to allow image editing. I also tested it with another camera app and it worked.
Image editing is really discouraged in this plugin.
hey guys: I was using version 4.2.0 and it was working well. Now I'm trying to install this version again and I'm not been able. What did happen to version 4.2.0 ?
hey guys: I was using version 4.2.0 and it was working well. Now I'm trying to install this version again and I'm not been able. What did happen to version 4.2.0 ?
Version 4.2.0 was never released because it contained https://github.com/apache/cordova-plugin-camera/pull/588 which broke some things on Android.
hey guys: I was using version 4.2.0 and it was working well. Now I'm trying to install this version again and I'm not been able. What did happen to version 4.2.0 ?
Version 4.2.0 was never released because it contained #588 which broke some things on Android.
ok! thanks a lot.
Hi, is there any update on this issue ? I'm using the plugin v5.0.1 and the app still crashes after taking a photo with the back camera
Are you able to provide a stacktrace of the crashes?
@PieterVanPoyer sorry for the late reply, this is what I got from the log
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=34, result=-1, data=null} to activity {de.myapp/de.myapp.MainActivity}: android.app.RecoverableSecurityException: de.myapp has no access to content://media/external/images/media/97
at android.app.ActivityThread.deliverResults(ActivityThread.java:4877)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4918)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7399)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)
Caused by: android.app.RecoverableSecurityException: de.myapp has no access to content://media/external/images/media/97
Btw I tested it with the front camera and it logged the same error.
Cordova-plugin-camera : v.5.0.1 cordova-android : 9.1.0 tested on Android 10 Devices
@PieterVanPoyer sorry for the late reply, this is what I got from the log
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=34, result=-1, data=null} to activity {de.myapp/de.myapp.MainActivity}: android.app.RecoverableSecurityException: de.myapp has no access to content://media/external/images/media/97 at android.app.ActivityThread.deliverResults(ActivityThread.java:4877) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4918) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7399) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980) Caused by: android.app.RecoverableSecurityException: de.myapp has no access to content://media/external/images/media/97
Btw I tested it with the front camera and it logged the same error.
Cordova-plugin-camera : v.5.0.1 cordova-android : 9.1.0 tested on Android 10 Devices
This plugin likely doesn't handle API 29/30 changes to external storage. There should be potential two workarounds for the time being:
requestLegacyExternalStorage
flag to the AndroidManifest.xml
fileAdding this to your config.xml
should work:
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:requestLegacyExternalStorage="true" />
</edit-config>
Note: requestLegacyExternalStorage
is ignored on API 30.
@breautek thank you for your help. now it works as expected
@lanadedstudio is this issue still occuring with the latest Cordova and Cordova plugins versions?
Yes, the problem persists
Cordova Version: 10.00 Cordova Plugin Camera Version: 5.0.1
I recently tested the error on smartphone models:
Smartphone Model: Moto G7 Play OS Version: Android 10
Smartphone Model: Asus_X00TDB OS Version: Android 9
When I installed an external camera app (not the android camera) it worked normally.
@PieterVanPoyer sorry for the late reply, this is what I got from the log
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=34, result=-1, data=null} to activity {de.myapp/de.myapp.MainActivity}: android.app.RecoverableSecurityException: de.myapp has no access to content://media/external/images/media/97 at android.app.ActivityThread.deliverResults(ActivityThread.java:4877) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4918) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7399) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980) Caused by: android.app.RecoverableSecurityException: de.myapp has no access to content://media/external/images/media/97
Btw I tested it with the front camera and it logged the same error. Cordova-plugin-camera : v.5.0.1 cordova-android : 9.1.0 tested on Android 10 Devices
This plugin likely doesn't handle API 29/30 changes to external storage. There should be potential two workarounds for the time being:
- Target API 29 and add
requestLegacyExternalStorage
flag to theAndroidManifest.xml
fileAdding this to your
config.xml
should work:<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application"> <application android:requestLegacyExternalStorage="true" /> </edit-config>
Note:
requestLegacyExternalStorage
is ignored on API 30.
- Fork this plugin and apply the PR fix(android): supports sdk-30 package visibility #684 This solution should work for both API 29 and API 30.
will this work with cordova-android 10.0.0 As due to https://github.com/apache/cordova-android/issues/1250 I removed all edit-config and config-file tags from my config.xml
will this work with cordova-android 10.0.0
The PR mentioned in my comment has been merged. You can give it a test by installing this plugin from github. cordova-android@10 is required as it contains breaking changes making it incompatible with cordova-android@9.
I confirm that upgrading to 6.0.0 along side updgrading to cordova 10 and cordova-android 10 works in our project.
Nb : If you upgrade cordova from 8 to 10, don't forget to add cordova-plugin-androidx-adapter plugin in your project, and verify gradle dependencies, in our case com.google.gms:google-services needs to be updated to 4.3.8.
Device: Motorola E7 with 4 GB RAM Android: 10
My solution was install Open Camera and use this app to take photos from my Cordova App.
Before Open Camera I was using the Motorola's Camera App that abruptly closes my app after I confirm a taken photo.
Im still seeing some instances of this error on Android devices, even with the latest release of this plugin and Cordova-android
android.app.RecoverableSecurityException$1.createFromParcel
Exception java.lang.RuntimeException:
at android.app.ActivityThread.deliverResults (ActivityThread.java:5994)
at android.app.ActivityThread.handleSendResult (ActivityThread.java:6033)
at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:67)
at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2574)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:226)
at android.os.Looper.loop (Looper.java:313)
at android.app.ActivityThread.main (ActivityThread.java:8762)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)
Caused by android.app.RecoverableSecurityException:
at android.app.RecoverableSecurityException$1.createFromParcel (RecoverableSecurityException.java:197)
at android.app.RecoverableSecurityException$1.createFromParcel (RecoverableSecurityException.java:194)
at android.os.Parcel.readParcelableInternal (Parcel.java:4787)
at android.os.Parcel.readParcelable (Parcel.java:4755)
at android.os.Parcel.createExceptionOrNull (Parcel.java:3018)
at android.os.Parcel.createException (Parcel.java:3007)
at android.os.Parcel.readException (Parcel.java:2990)
at android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:190)
at android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:142)
at android.content.ContentProviderProxy.delete (ContentProviderNative.java:629)
at android.content.ContentResolver.delete (ContentResolver.java:2340)
at android.content.ContentResolver.delete (ContentResolver.java:2306)
at org.apache.cordova.camera.CameraLauncher.checkForDuplicateImage (CameraLauncher.java:1277)
at org.apache.cordova.camera.CameraLauncher.cleanup (CameraLauncher.java:1242)
at org.apache.cordova.camera.CameraLauncher.processResultFromCamera (CameraLauncher.java:626)
at org.apache.cordova.camera.CameraLauncher.onActivityResult (CameraLauncher.java:877)
at org.apache.cordova.CordovaInterfaceImpl.onActivityResult (CordovaInterfaceImpl.java:160)
at org.apache.cordova.CordovaActivity.onActivityResult (CordovaActivity.java:375)
at android.app.Activity.dispatchActivityResult (Activity.java:8951)
at android.app.ActivityThread.deliverResults (ActivityThread.java:5987)
according to the Google Play Console, its happening on different devices on Android 13
Issue Type
Description
The app crashes when the photo is captured. Error checked on Android 9 and 10, on IOS works well
Information
Command or Code
Environment, Platform, Device
Version information
Cordova Packages:
Project Installed Platforms:
Project Installed Plugins:
Checklist