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

[Bug] 2.15 Crash TagsDialog not attached to a Context #8973

Closed
4 tasks
mikehardy opened this issue May 26, 2021 · 5 comments · Fixed by #9011
Closed
4 tasks

[Bug] 2.15 Crash TagsDialog not attached to a Context #8973

mikehardy opened this issue May 26, 2021 · 5 comments · Fixed by #9011
Labels
Help Wanted Requesting Pull Requests from volunteers

Comments

@mikehardy
Copy link
Member

mikehardy commented May 26, 2021

Reproduction Steps
  • Add Note
  • Tap Tags
  • Tap Add
  • Type in text box
  • Leave AnkiDroid
  • Restore AnkiDroid
  • TextBox is still there, Tags Dialog has been removed
  • Press "OK"
  • Crash
Expected Result
Actual Result

On Android 11 AnkiDroid 2.15.1:

java.lang.IllegalStateException: Fragment TagsDialog{c83353f} (4c0ff020-c55f-4c86-8ad9-9748aa4e36f8) not attached to a context.
at androidx.fragment.app.Fragment.requireContext(Fragment.java:2)
at androidx.fragment.app.Fragment.getResources(Fragment.java:1)
at androidx.fragment.app.Fragment.getString(Fragment.java:2)
at com.ichi2.anki.dialogs.tags.TagsDialog.addTag(TagsDialog.java:7)
at com.ichi2.anki.dialogs.tags.TagsDialog.lambda$null$3(TagsDialog.java:1)
at com.ichi2.anki.dialogs.tags.TagsDialog.c(Unknown Source:0)
at com.ichi2.anki.dialogs.tags.d.onInput(Unknown Source:2)
at com.afollestad.materialdialogs.MaterialDialog.onClick(MaterialDialog.java:13)
at android.view.View.performClick(View.java:8160)
at android.widget.TextView.performClick(TextView.java:16220)
at android.view.View.performClickInternal(View.java:8137)
at android.view.View.access$3700(View.java:888)
at android.view.View$PerformClick.run(View.java:30236)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8512)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeI
no logcat :-(
Debug info

Refer to the support page if you are unsure where to get the "debug info".

Research

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

  • I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
  • I have checked the manual and the FAQ and could not find a solution to my issue
  • I have searched for similar existing issues here and on the user forum
  • (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)
@mikehardy mikehardy added the Help Wanted Requesting Pull Requests from volunteers label May 26, 2021
@mikehardy mikehardy added this to the 2.15.3 release milestone May 26, 2021
@prateek-singh-3212
Copy link
Member

@mikehardy I have started working on this. Without logcat, I figured out that this issue is caused due to unhandled requireActivity() in the code. If possible, can you please share the logcat? should I make a PR after handling this exception?

MaterialDialog.Builder addTagBuilder = new MaterialDialog.Builder(requireActivity())

@mikehardy
Copy link
Member Author

There was no logcat in the crash report, sorry. I posted everything I had. It could be similar to the one near it #8972 ?

@david-allison
Copy link
Member

david-allison commented May 29, 2021

Repro steps (edited into main post)

  • Add Note
  • Tap Tags
  • Tap Add
  • Type in text box
  • Leave AnkiDroid
  • Restore AnkiDroid
  • TextBox is still there, Tags Dialog has been removed
  • Press "OK"
2021-05-29 04:06:50.675 24418-24418/com.ichi2.anki E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ichi2.anki, PID: 24418
    java.lang.IllegalStateException: Fragment TagsDialog{7759d21} (aeab739e-ca79-4735-9352-dab8bac8d1b6) not attached to a context.
        at androidx.fragment.app.Fragment.requireContext(Fragment.java:900)
        at androidx.fragment.app.Fragment.getResources(Fragment.java:964)
        at androidx.fragment.app.Fragment.getString(Fragment.java:999)
        at com.ichi2.anki.dialogs.tags.TagsDialog.addTag(TagsDialog.java:283)
        at com.ichi2.anki.dialogs.tags.TagsDialog.lambda$adjustToolbar$3$TagsDialog(TagsDialog.java:213)
        at com.ichi2.anki.dialogs.tags.-$$Lambda$TagsDialog$6PhrrCr6C3X737UarQIRq71QhIk.onInput(Unknown Source:2)
        at com.afollestad.materialdialogs.MaterialDialog.onClick(MaterialDialog.java:419)
        at android.view.View.performClick(View.java:7448)
        at android.view.View.performClickInternal(View.java:7425)
        at android.view.View.access$3600(View.java:810)
        at android.view.View$PerformClick.run(View.java:28305)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7660)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

@prateek-singh-3212
Copy link
Member

prateek-singh-3212 commented May 29, 2021

Sorry! My bad. I didn't read the reproduction steps correctly. 🙇

@david-allison
Copy link
Member

Sorry! My bad. I didn't read the reproduction steps correctly. 🙇

I added it in when I made the comment. Not your fault! Thanks for the help

prateek-singh-3212 added a commit to prateek-singh-3212/Anki-Android that referenced this issue May 30, 2021
prateek-singh-3212 added a commit to prateek-singh-3212/Anki-Android that referenced this issue May 31, 2021
prateek-singh-3212 added a commit to prateek-singh-3212/Anki-Android that referenced this issue May 31, 2021
mikehardy pushed a commit that referenced this issue Jun 1, 2021
mikehardy pushed a commit that referenced this issue Jun 2, 2021
(cherry picked from commit a4ab14c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted Requesting Pull Requests from volunteers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants