Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

[Bug] Crop image failure on Android 9

Open jyant99 opened this issue 5 years ago • 24 comments

Screenshot_2021-01-31_113253

Reproduction Steps
Expected Result
Actual Result
Debug info

[AnkiDroid Version = 2.14.3 Android Version = 9 ACRA UUID = b3973648-5cc1-4924-8034-51341545f4dd Scheduler = std Crash Reports Enabled = true ]

Research

Enter an [x] character to confirm the points below:

  • [x] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
  • [x] I have checked the manual and the FAQ and could not find a solution to my issue
  • [x] I have searched for similar existing issues here and on the user forum
  • [x] (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)

jyant99 avatar Jan 31 '21 06:01 jyant99

Hi, thanks for the report.

Could you please fill out the Debug Info section?

Thanks

david-allison avatar Jan 31 '21 10:01 david-allison

Hi, thanks for the report.

Could you please fill out the Debug Info section?

Thanks

AnkiDroid Version = 2.14.3

Android Version = 9

ACRA UUID = b3973648-5cc1-4924-8034-51341545f4dd

Scheduler = std

Crash Reports Enabled = true

jyant99 avatar Jan 31 '21 10:01 jyant99

Lots of crash reports there. Nothing recent. Has this been going on for a long while?

Potentially: https://couchdb.ankidroid.org/acralyzer/_design/acralyzer/index.html#/report-details/912244e4-14a1-41ed-a359-217a02366cd6

java.lang.IllegalArgumentException: Failed to find configured root that contains /
at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:13)
at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:2)
at com.ichi2.anki.multimediacard.fields.BasicImageFieldController.getUriForFile(BasicImageFieldController.java:3)
at com.ichi2.anki.multimediacard.fields.BasicImageFieldController.createUI(BasicImageFieldController.java:5)
at com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity.recreateEditingUi(MultimediaEditFieldActivity.java:16)
at com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity.onCreate(MultimediaEditFieldActivity.java:17)
at android.app.Activity.performCreate(Activity.java:7149)
at android.app.Activity.performCreate(Activity.java:7140)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3017)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

david-allison avatar Jan 31 '21 11:01 david-allison

Lots of crash reports there. Nothing recent. Has this been going on for a long while?

Potentially: https://couchdb.ankidroid.org/acralyzer/_design/acralyzer/index.html#/report-details/912244e4-14a1-41ed-a359-217a02366cd6

java.lang.IllegalArgumentException: Failed to find configured root that contains /
at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:13)
at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:2)
at com.ichi2.anki.multimediacard.fields.BasicImageFieldController.getUriForFile(BasicImageFieldController.java:3)
at com.ichi2.anki.multimediacard.fields.BasicImageFieldController.createUI(BasicImageFieldController.java:5)
at com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity.recreateEditingUi(MultimediaEditFieldActivity.java:16)
at com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity.onCreate(MultimediaEditFieldActivity.java:17)
at android.app.Activity.performCreate(Activity.java:7149)
at android.app.Activity.performCreate(Activity.java:7140)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3017)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Yes for a long time

jyant99 avatar Jan 31 '21 11:01 jyant99

If this is yet to be solved , can I work on this?

imaryandokania avatar Mar 21 '21 04:03 imaryandokania

Hold on this one - I've just implemented uCrop as a dependency for Android 11 on the release-2.14 branch as an experiment (Android 11 had no working crop prior, so it couldn't do harm) and I want to either expand it's use to all APIs or - pending an investigation of another library maintained by someone I've had a chat with while integrating uCrop - maybe replace it entirely.

In other words: it's in flux and I need to make a high level decision on what library to use going forward even, then implement it, then likely this goes away

mikehardy avatar Mar 21 '21 04:03 mikehardy

Hold on this one - I've just implemented uCrop as a dependency for Android 11 on the release-2.14 branch as an experiment (Android 11 had no working crop prior, so it couldn't do harm) and I want to either expand it's use to all APIs or - pending an investigation of another library maintained by someone I've had a chat with while integrating uCrop - maybe replace it entirely.

In other words: it's in flux and I need to make a high level decision on what library to use going forward even, then implement it, then likely this goes away

cool

imaryandokania avatar Mar 21 '21 04:03 imaryandokania

Hold on this one - I've just implemented uCrop as a dependency for Android 11 on the release-2.14 branch as an experiment (Android 11 had no working crop prior, so it couldn't do harm) and I want to either expand it's use to all APIs or - pending an investigation of another library maintained by someone I've had a chat with while integrating uCrop - maybe replace it entirely.

In other words: it's in flux and I need to make a high level decision on what library to use going forward even, then implement it, then likely this goes away

Just for help I would suggest instead of u crop we can use https://github.com/ArthurHub/Android-Image-Cropper.git , This work pretty well.

imaryandokania avatar Mar 21 '21 05:03 imaryandokania

Just for help I would suggest instead of u crop we can use https://github.com/ArthurHub/Android-Image-Cropper.git , This work pretty well.

It hasn't been updated since 2019

david-allison avatar Mar 21 '21 05:03 david-allison

Just for help I would suggest instead of u crop we can use https://github.com/ArthurHub/Android-Image-Cropper.git , This work pretty well.

It hasn't been updated since 2019

I have been using it in my some of the projects and didn't face any issues with this library, only change is adding implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+' to dependencies, still I will search for some more updated ones.

imaryandokania avatar Mar 21 '21 06:03 imaryandokania

@david-allison-1 This issue happens with Android 7 (faced this one but not on this app) and Android 9. Just a small fix is required. It is related to storage (FileProvider) and not with cropping.

mrudultora avatar Mar 21 '21 10:03 mrudultora

@imaryandokania I will not adopt an abandoned library "I haven't had any problems" is not a valid defense

uCrop itself is abandoned which is why I mentioned I was talking with the maintainer of another project.

Cropping done correctly is not easy at all, if you've never tried it, you can't imagine the problems handling various phones and a large Android API skew

reference https://github.com/Yalantis/uCrop/issues/715#issuecomment-800678952

Related to the library you mention, the currently alive fork is I think https://github.com/CanHub/Android-Image-Cropper - with the maintainer I was chatting with

mikehardy avatar Mar 21 '21 16:03 mikehardy

I guess if you have adopted that specific library before and you were interested, you could attempt to replace all our cropping with the link I just pasted (https://github.com/CanHub/Android-Image-Cropper) as it appears to be alive and was based on working code (as you have experienced) from a maintainer that is familiar with the real intricacies of cropping

If we get successful crop tests from API21 through API31 I would accept a PR for that and it would be help - but it needs solid testing. If it doesn't work then we'll use uCrop as it is abandoned but is also a massive community (the biggest in the Android crop space) so the code will eventually find a home and ongoing maintenance

mikehardy avatar Mar 21 '21 16:03 mikehardy

I guess if you have adopted that specific library before and you were interested, you could attempt to replace all our cropping with the link I just pasted (https://github.com/CanHub/Android-Image-Cropper) as it appears to be alive and was based on working code (as you have experienced) from a maintainer that is familiar with the real intricacies of cropping

If we get successful crop tests from API21 through API31 I would accept a PR for that and it would be help - but it needs solid testing. If it doesn't work then we'll use uCrop as it is abandoned but is also a massive community (the biggest in the Android crop space) so the code will eventually find a home and ongoing maintenance

Yes this seems to the forked from the one I had mentioned and seems updated, so seem to be familiar! I can work on this!

imaryandokania avatar Mar 21 '21 16:03 imaryandokania

I am going to mark this for release-2.16, moving it from release-2.15

The general idea now is to do an exploratory PR that uses https://github.com/CanHub/Android-Image-Cropper for all APIs (vs our split "custom crop for Android < 11" / "uCrop for Android 11" solution)

If that library cannot do it, then implementing uCrop for all APIs and watching closely for where the community goes (whenever a valid fork appears).

mikehardy avatar Apr 04 '21 17:04 mikehardy

I am going to mark this for release-2.16, moving it from release-2.15

The general idea now is to do an exploratory PR that uses https://github.com/CanHub/Android-Image-Cropper for all APIs (vs our split "custom crop for Android < 11" / "uCrop for Android 11" solution)

If that library cannot do it, then implementing uCrop for all APIs and watching closely for where the community goes (whenever a valid fork appears).

@mikehardy please let us know if you find any issues with Android Image Cropper I'm working my head around improving the final URI, because of Android 10/11 changes, but hopefully soon we get a clear usage of it ;). This don't affect most of usage, but some specific cases where people try to use the URI to create a file. Anyway we can always find a solution

Canato avatar Apr 06 '21 08:04 Canato

@imaryandokania are you still active on this issue ?, if not then I will do this,

The general idea now is to do an exploratory PR that uses https://github.com/CanHub/Android-Image-Cropper for all APIs (vs our split "custom crop for Android < 11" / "uCrop for Android 11" solution)

So @mikehardy,I only have to use Android-Image-Cropper in the application, am I right?

Akshay0701 avatar Apr 24 '21 18:04 Akshay0701

Ideally, Android-Image-Cropper works fabulously and all image cropping is replaced with it, yes

mikehardy avatar Apr 24 '21 19:04 mikehardy

When I used Android-Image-Cropper it's showing me this message

The System does not have an app installed that can perform this action

Akshay0701 avatar Apr 28 '21 07:04 Akshay0701

And when i used UCrop it work fine ,so should I go with uCrop for all API?

Akshay0701 avatar Apr 28 '21 07:04 Akshay0701