cordova-plugin-crop
cordova-plugin-crop copied to clipboard
Failed image crop selected from gallery
Hi,
I have been using this plugin and it gives me error while I try to upload image from gallery and crop it says Failed image crop plugin and When I track the issue some permission related issue is coming but I have already given all kind of permission for red and write in Android Manifest File in ionic project
This is possibly related to the new permission system in marshmallow. If using that, setting the permissions in Android Manifest is not enough. You can try to set those manually in your test device.
Here's the relevant documentation. https://developer.android.com/training/permissions/requesting.html
Okay so for Android 6.0+ the plugin needs a way to check if permission isn't allowed, and if not, ask for permission? or maybe use another plugin for it like https://www.npmjs.com/package/cordova-plugin-android-permissions i guess?
[INFO:CONSOLE(1983)] "================= from isValidImage
==================", source:
file:///android_asset/www/js/controllers/appCtrl.js (1983)
07-04 15:20:49.368 12461-12461/com.linkstreet.apps.mlink I/chromium:
[INFO:CONSOLE(1984)] "
https://mlink.linkstreet.in:8001/v1/public/api/media/image/4e592cc0-41cc-11e6-96ad-af08d744f099",
source: file:///android_asset/www/js/controllers/appCtrl.js (1984)
07-04 15:21:04.055 12461-12461/com.linkstreet.apps.mlink I/Timeline:
Timeline: Activity_idle id: android.os.BinderProxy@27a5a9e9 time:200174660
07-04 15:21:04.196 12461-12640/com.linkstreet.apps.mlink I/Timeline:
Timeline: Activity_launch_request id:com.linkstreet.apps.mlink
time:200174801
07-04 15:21:04.253 12461-12551/com.linkstreet.apps.mlink I/art: Explicit
concurrent mark sweep GC freed 1901(170KB) AllocSpace objects, 7(480KB) LOS
objects, 40% free, 19MB/31MB, paused 2.866ms total 68.949ms
07-04 15:21:04.264 12461-12461/com.linkstreet.apps.mlink E/JHEAD: can't
open
'/storage/emulated/0/Android/data/com.linkstreet.apps.mlink/cache/IMG-20160702-WA0007.jpg?1467625864184'
07-04 15:21:04.274 12461-12461/com.linkstreet.apps.mlink E/android-crop:
Error reading image:
/storage/emulated/0/Android/data/com.linkstreet.apps.mlink/cache/IMG-20160702-WA0007.jpg?1467625864184:
open failed: ENOENT (No such file or directory)
java.io.FileNotFoundException:
/storage/emulated/0/Android/data/com.linkstreet.apps.mlink/cache/IMG-20160702-WA0007.jpg?1467625864184:
open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at
android.content.ContentResolver.openInputStream(ContentResolver.java:667)
at
com.soundcloud.android.crop.CropImageActivity.calculateBitmapSampleSize(CropImageActivity.java:147)
at
com.soundcloud.android.crop.CropImageActivity.setupFromIntent(CropImageActivity.java:125)
at
com.soundcloud.android.crop.CropImageActivity.onCreate(CropImageActivity.java:74)
at android.app.Activity.performCreate(Activity.java:6072)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5298)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file
or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at
android.content.ContentResolver.openInputStream(ContentResolver.java:667)
at
com.soundcloud.android.crop.CropImageActivity.calculateBitmapSampleSize(CropImageActivity.java:147)
at
com.soundcloud.android.crop.CropImageActivity.setupFromIntent(CropImageActivity.java:125)
at
com.soundcloud.android.crop.CropImageActivity.onCreate(CropImageActivity.java:74)
at android.app.Activity.performCreate(Activity.java:6072)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5298)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
I am facing this issues on every device not only on marshmallow On Jul 4, 2016 3:24 PM, "Akhilesh Bamhore" [email protected] wrote:
[INFO:CONSOLE(1983)] "================= from isValidImage ==================", source: file:///android_asset/www/js/controllers/appCtrl.js (1983)
07-04 15:20:49.368 12461-12461/com.linkstreet.apps.mlink I/chromium: [INFO:CONSOLE(1984)] " https://mlink.linkstreet.in:8001/v1/public/api/media/image/4e592cc0-41cc-11e6-96ad-af08d744f099", source: file:///android_asset/www/js/controllers/appCtrl.js (1984)
07-04 15:21:04.055 12461-12461/com.linkstreet.apps.mlink I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@27a5a9e9 time:200174660
07-04 15:21:04.196 12461-12640/com.linkstreet.apps.mlink I/Timeline: Timeline: Activity_launch_request id:com.linkstreet.apps.mlink time:200174801
07-04 15:21:04.253 12461-12551/com.linkstreet.apps.mlink I/art: Explicit concurrent mark sweep GC freed 1901(170KB) AllocSpace objects, 7(480KB) LOS objects, 40% free, 19MB/31MB, paused 2.866ms total 68.949ms
07-04 15:21:04.264 12461-12461/com.linkstreet.apps.mlink E/JHEAD: can't open '/storage/emulated/0/Android/data/com.linkstreet.apps.mlink/cache/IMG-20160702-WA0007.jpg?1467625864184'
07-04 15:21:04.274 12461-12461/com.linkstreet.apps.mlink E/android-crop: Error reading image: /storage/emulated/0/Android/data/com.linkstreet.apps.mlink/cache/IMG-20160702-WA0007.jpg?1467625864184: open failed: ENOENT (No such file or directory)
java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.linkstreet.apps.mlink/cache/IMG-20160702-WA0007.jpg?1467625864184: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.
(FileInputStream.java:76) at java.io.FileInputStream.
(FileInputStream.java:103) at android.content.ContentResolver.openInputStream(ContentResolver.java:667)
at com.soundcloud.android.crop.CropImageActivity.calculateBitmapSampleSize(CropImageActivity.java:147)
at com.soundcloud.android.crop.CropImageActivity.setupFromIntent(CropImageActivity.java:125)
at com.soundcloud.android.crop.CropImageActivity.onCreate(CropImageActivity.java:74)
at android.app.Activity.performCreate(Activity.java:6072)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5298)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
at java.io.FileInputStream.
(FileInputStream.java:76) at java.io.FileInputStream.
(FileInputStream.java:103) at android.content.ContentResolver.openInputStream(ContentResolver.java:667)
at com.soundcloud.android.crop.CropImageActivity.calculateBitmapSampleSize(CropImageActivity.java:147)
at com.soundcloud.android.crop.CropImageActivity.setupFromIntent(CropImageActivity.java:125)
at com.soundcloud.android.crop.CropImageActivity.onCreate(CropImageActivity.java:74)
at android.app.Activity.performCreate(Activity.java:6072)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5298)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
07-04 15:21:04.368 12461-12461/com.linkstreet.apps.mlink I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@27a5a9e9 time:200174972
On Jul 4, 2016 1:42 PM, "matte5031" [email protected] wrote:
Okay so for Android 6.0+ the plugin needs a way to check if permission isn't allowed, and if not, ask for permission?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jeduan/cordova-plugin-crop/issues/19#issuecomment-230231058, or mute the thread https://github.com/notifications/unsubscribe/ALFncKgs-0DNMMP-ngTFC4K4YwRKD09bks5qSMBUgaJpZM4JEEJ- .
This version works on even on Android 7! https://github.com/Nexxa/cordova-plugin-crop
The specific commits that I believe fixes this is: https://github.com/Nexxa/cordova-plugin-crop/commit/4bf0144eccd3543069336bfa2b1f4d0fa9245bcc
@gianpaj @StefanoMagrassi great work! Interested in getting this plugin transferred?
@jeduan thank you very much, but actually I'm neither an Android nor iOS developer... You did a great job with these plugin and I just fixed some trivial bug.
Neither am I!
Nice fix! @StefanoMagrassi ! However for me some images have worse quality though, i believe it might be because it is trying to resize the image to either the default 1080 or whatever value is set in the options of {Number} [toSize=1080] . Is there anything that can be changed in the code so that it doesn't try to resize the the image. In that case what? Any help or input is highly appreciated, thanks!
@matte5031 nope... My fork aimed to be used in order to produce a squared image with a configurable final size (or 1080px as default).
If you need to avoid this behavior you should add a condition in these lines: 76 and 77 for Android, 76 for iOS.
I probably won't do any change/enhancement because I've no time and the project in which I used my fork works fine.
Thanks @StefanoMagrassi , the resize seem to work fine, not sure how to use it from the javascript though! Now i use this code and the options toSize are being ignored, am i not supposed to set options like this? Would really appreciate if you could guide me on if this is correct or if it needs to be changed somehow, thanks alot!
var options = { quality:100, toSize: 480 };
plugins.crop.promise(imageURI, options)
Add these lines in your config file. It should work fine.
<config-file parent="/manifest/application" platform="android" target="AndroidManifest.xml">
<activity android:label="@string/multi_app_name" android:name="com.soundcloud.android.crop.CropImageActivity" android:theme="@style/Theme.AppCompat.Light" />
</config-file>