ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.65k stars 2.24k forks source link

[Bug] Crop image failure on Android 9 #8072

Closed jyant99 closed 3 years ago

jyant99 commented 3 years ago

[]() 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:

david-allison commented 3 years ago

Hi, thanks for the report.

Could you please fill out the Debug Info section?

Thanks

jyant99 commented 3 years ago

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

david-allison commented 3 years ago

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)
jyant99 commented 3 years ago

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

imaryandokania commented 3 years ago

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

mikehardy commented 3 years ago

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

imaryandokania commented 3 years ago

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 commented 3 years ago

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.

david-allison commented 3 years ago

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

imaryandokania commented 3 years ago

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.

mrudultora commented 3 years ago

@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.

mikehardy commented 3 years ago

@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 commented 3 years ago

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

imaryandokania commented 3 years ago

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!

mikehardy commented 3 years ago

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).

Canato commented 3 years ago

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

Akshay0701 commented 3 years ago

@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?

mikehardy commented 3 years ago

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

Akshay0701 commented 3 years ago

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 commented 3 years ago

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

Canato commented 3 years ago

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

Hey @Akshay0701 jus to say that this message is not from the library, maybe the library has some error, but Anki is mapping it in this message

mikehardy commented 3 years ago

Yeah, unfiltered adb logcat should have something interesting in there. That's usually the message when we fire off an intent to an external editing program, but with these library integrations it should be internal :thinking:

github-actions[bot] commented 3 years ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

mikehardy commented 3 years ago

Still have plans for this one