Yalantis / uCrop

Image Cropping Library for Android
https://yalantis.com/blog/introducing-ucrop-our-own-image-cropping-library-for-android/
11.86k stars 2.16k forks source link

Error After Crop 'Is a directory' #53

Closed HosseinKurd closed 8 years ago

HosseinKurd commented 8 years ago

I tried to crop photo and fix some errors

at onActivityResult Log Errors

if(resultCode == UCrop.RESULT_ERROR){ Throwable cropError = UCrop.getError(data); LTH.eLog(PHOTO_TAG, PurchaseAsync.TAG + " -> UCrop RESULT ERROR"); LTH.eLog(PHOTO_TAG, PurchaseAsync.TAG + " -> Error In Crop : " + cropError.getMessage(), cropError); }

Message : Is a directory

java.io.FileNotFoundException: Is a directory
        at android.os.Parcel.openFileDescriptor(Native Method)
        at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:252)
        at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:198)
        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:899)
        at android.content.ContentResolver.openOutputStream(ContentResolver.java:669)
        at android.content.ContentResolver.openOutputStream(ContentResolver.java:645)
        at com.yalantis.ucrop.UCropActivity.cropAndSaveImage(UCropActivity.java:534)
        at com.yalantis.ucrop.UCropActivity.onOptionsItemSelected(UCropActivity.java:124)
        at android.app.Activity.onMenuItemSelected(Activity.java:2600)
        at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:404)
        at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:167)
        at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:100)
        at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:100)
        at android.support.v7.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:69)
        at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:169)
        at android.support.v7.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:760)
        at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:811)
        at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
        at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:958)
        at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:948)
        at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:618)
        at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:139)
        at android.view.View.performClick(View.java:4438)
        at android.view.View$PerformClick.run(View.java:18422)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5017)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
        at dalvik.system.NativeStart.main(Native Method)
timkoers commented 8 years ago

Please take a look at the sample app and code. That code works for me.

Van: HosseinKurd notifications@github.com verzonden: 7 mrt. 2016 10:46 AM Aan: Yalantis/uCrop Onderwerp: [uCrop] Error After Crop 'Is a directory' (#53)

I tried to crop photo and fix some errors

at onActivityResult Log Errors

if(resultCode == UCrop.RESULT_ERROR){ Throwable cropError = UCrop.getError(data); LTH.eLog(PHOTO_TAG, PurchaseAsync.TAG + " -> UCrop RESULT ERROR"); LTH.eLog(PHOTO_TAG, PurchaseAsync.TAG + " -> Error In Crop : " + cropError.getMessage(), cropError); }

Message : Is a directory

java.io.FileNotFoundException: Is a directory
        at android.os.Parcel.openFileDescriptor(Native Method)
        at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:252)
        at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:198)
        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:899)
        at android.content.ContentResolver.openOutputStream(ContentResolver.java:669)
        at android.content.ContentResolver.openOutputStream(ContentResolver.java:645)
        at com.yalantis.ucrop.UCropActivity.cropAndSaveImage(UCropActivity.java:534)
        at com.yalantis.ucrop.UCropActivity.onOptionsItemSelected(UCropActivity.java:124)
        at android.app.Activity.onMenuItemSelected(Activity.java:2600)
        at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:404)
        at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:167)
        at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:100)
        at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:100)
        at android.support.v7.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:69)
        at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:169)
        at android.support.v7.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:760)
        at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:811)
        at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
        at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:958)
        at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:948)
        at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:618)
        at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:139)
        at android.view.View.performClick(View.java:4438)
        at android.view.View$PerformClick.run(View.java:18422)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5017)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
        at dalvik.system.NativeStart.main(Native Method)

Reply to this email directly or view it on GitHub: https://github.com/Yalantis/uCrop/issues/53

HosseinKurd commented 8 years ago

Thank You I Found It UCrop.of(uri, mImageCaptureUri) Instead Of UCrop.of(mImageCaptureUri, getUriFromPath())

From onActivityResult Intent data , data.getData() Is Input Value To doCrop

HosseinKurd commented 8 years ago

But On Huawei P7 shows Error In Crop : Permission denied

shliama commented 8 years ago

Permission denied

I guess that's because you do not handle Android M permissions.

HosseinKurd commented 8 years ago

Only one device ? Huawei P7 is root Device

shliama commented 8 years ago

Permission denied to open Uri with source image or to save resulting image?

PGMacDesign commented 8 years ago

Took some digging, but figured out the issue. Basically, it is a KitKat permissions problem (Any device on 4.4,4+ will have it). YOU (the app creator) have requested permission for the app to work on these files that require permission. THEY (any third party library using the photo for, let's say, cropping) do not have explicit permission from the system to access it.

Simple solution: When you get the photoUri back from the intent, before you call the crop activity on the Uri, just make a copy in cache and send the Uri to THAT file instead. Code sample here if you need it.