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

Error After Crop 'Is a directory' #53

Closed
HosseinKurd opened this issue Mar 7, 2016 · 7 comments
Closed

Error After Crop 'Is a directory' #53

HosseinKurd opened this issue Mar 7, 2016 · 7 comments

Comments

@HosseinKurd
Copy link

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
Copy link
Contributor

timkoers commented Mar 7, 2016

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:
#53

@HosseinKurd
Copy link
Author

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
Copy link
Author

But On Huawei P7 shows Error In Crop : Permission denied

@shliama
Copy link
Contributor

shliama commented Mar 9, 2016

Permission denied

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

@HosseinKurd
Copy link
Author

Only one device ? Huawei P7 is root Device

@shliama
Copy link
Contributor

shliama commented Mar 9, 2016

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

@shliama shliama closed this as completed Apr 7, 2016
@PGMacDesign
Copy link
Contributor

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.

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

4 participants