App crashes after selecting Ankidroid for flashcards

Hi there,

I just got a new phone and set up Pleco on it. On my previous phone (also Android) I had set Pleco to use Ankidroid for the flashcards and it was working just fine.

After getting the new phone I changed the setting to use Ankidroid for flashcards, it changed but the deck selection and all other settings were blank. I closed everything and reopened both Pleco and Ankidroid.

I went back into Pleco and had to select Ankidroid again, but this time the app crashed, and crashed again every time after I opened it. I reset my phone and tried opening Pleco again but it just closed immediately.

After that I deleted Pleco and reinstalled, it worked fine but as soon as I chose Ankidroid for flashcards it crashes immediately and crashes less than a second after opening it again.

I just updated my android OS to the latest version and it still crashes.

Phone info (not sure how useful this is):

Phone: Xiaomi Redmi K30, MIUI 11.0.5
Android verison: 10
Android security patch: 2019-11-01
 

mikelove

皇帝
Staff member
Hmm... what version of AnkiDroid are you using? Is it working correctly on your phone other than this? And are you granting permission for Pleco to access your AnkiDroid database when prompted?
 
I'm using the latest Ankidroid. I can't find a version number but it's the latest on Google Play store (Oct 15, 2019)

Everything is working perfectly on the other phone.

I wasn't prompted for permissions, although I did go in and grant all permissions to Pleco in the system settings, but it still crashes.

I also updated Pleco today and it still crashes. I tried deleting and reinstalling again but it didn't help.
 

mikelove

皇帝
Staff member
Did that include the 'additional permission' for accessing AnkiDroid data? Or did the option for that not even show up?

We've had a few other reports of this so far but our initial assessment is that it's a bug in third-party permission prompts on MIUI 11; every user who's reported this issue so far has been using a Xiaomi phone with MIUI 11. (doesn't seem to matter if it's Android 9 or 10, it's something in the MIUI 11 skin specifically)

Could you try deleting Pleco and then installing the APK version downloaded directly from our website instead? (that will report crashes to us through our system instead of Google's and thus should hopefully give us more useful crash logs than what we're seeing so far)
 
I didn't see any pop ups asking for any permissions, the app just closes. (I can't remember if I did on the old phone either. Would you like me to reinstall Pleco there and check?)

I think my old phone did have the previous MIUI version, I still have it so I can try to update it and see if that breaks Pleco, if that's of any use to you?

Ok I've installed the APK from the site and let it crash a few times.
 

mikelove

皇帝
Staff member
No crashes coming through, which suggests this may be happening somewhere outside of our app's control.

So if you go into the system Settings app and look at Pleco's details page, is the AnkiDroid permission even listed there under 'additional permissions'?
 
It doesn't look like there is even a place for "additional permissions" or anything like that. I've attached screenshots of the Pleco app page and the permissions screen.

Some of the permissions are disabled in the picture but that's because I cleared all the app data to get Pleco to stop crashing (I guess it resets the setting). I've tried enabling everything on that page and then selecting Ankidroid but it still crashes.

As an aside, I just started up my old phone and the permissions page looks the same as this screenshot.

WeChat Image_20200103191143.pngWeChat Image_20200103191153.jpg
 

mikelove

皇帝
Staff member
Is there also a section that lists permissions and which apps have them? (i.e., that groups by permission instead of by app) Does anything related to AnkiDroid show up in there?

The fact that the screen is the same doesn't necessarily mean that the underlying implementation hasn't changed, i.e. it could be that a previous MIUI version wasn't enforcing that permission but the new one is. Or it could be something unrelated to permissions at all, it's just kind of odd that this particular issue is (as far as we can tell) only happening in one particular version of MIUI and that MIUI is doing something odd with AnkiDroid third party app permissions.
 
The only other permissions page I can find is this one:

WeChat Image_20200107225706.png

It doesn't seem like Pleco or Ankidroid are in any of those categories to turn on or off.

I'm not sure if this information is useful, but I've been playing around:

-After setting Ankidroid as the flashcard system, Pleco doesn't always crash immediately, I sometimes I have to change a card or try change a setting for it to crash.
-Once it's crashed, it will crash on start up every time.
-Today I went into ankidroid and disabled the API (advanced settings), when I went into Pleco it didn't crash immediately, instead it said that Ankidroid is missing and it can't find a copy on the phone. After that I could use Pleco normally.
-When I re-enabled the API in ankidroid and go back into Pleco it's fine until I do something related to flashcards, then it goes back to crashing.

One thing I can do without crashing Pleco is to say "open Ankidroid" in the menu. It goes to Ankidroid no problem and I can go back into Pleco without crashing until I try change a setting or create a card.
 
An update (once again, I'm not sure if this is useful):

I just had Pleco open with the Anki API disabled, in the main menu there is an option to "Open Ankidroid". I pressed it but instead of taking me to the Ankidroid app it took me the the "System Tracing" app (see screenshot)

36b322f10d8f7b0e51109034fc3f02b.jpg
 

mikelove

皇帝
Staff member
Interesting. We've now gotten a phone set up with MIUI 11 here but no luck reproducing the problem so far - seems like not only do you have to have MIUI 11 but there also has to be some as yet unspecified thing incorrect about or set up a certain way with your system.
 

mikelove

皇帝
Staff member
@Mark Havemann - someone suggested the following fix by email:

1) Turn on Developer Options if you haven't already - go into Settings / About Phone and tap on 'MIUI Version' a bunch of times until it says you're a developer.

2) Go into Additional Settings / Developer Options and turn off the "Turn on MIUI Optimization" option at the bottom.

3) Check Pleco's permission settings now - is there an option to give it permission to access AnkiDroid?
 
Amazing, that has made available the option for allowing permissions to Ankidroid. After doing what you suggested, everything works perfectly.

Some notes for anyone else who has the problem.

To enable developer mode on MIUI 11:
Settings -> my device -> all specs -> MIUI version (tap this 7 times)

After disabling MIUI Optimizations, the permissions to allow Pleco to access Ankidroid aren't in the settings menu (not anywhere I could find anyway), rather you need to long press the app icon until the little extra menu pops up, then choose "App Info", and extra options can be found there.

Turning off MIUI Optimizations seemed to make the UI a little sluggish, so I re-enabled it and everything still works fine with Pleco and Ankidroid.


Thanks for all your help Mike, and thanks to whoever made the suggestion to turn of MIUI Optimizations!
 

caesartg

榜眼
Okay, just selecting the Ankidroid option seems to have broken my Pleco and it crashed. I took the steps above and lots of weird stuff started to happening (keyboard changed, graphics changed, got lots of notifications from other software), so I tried to roll it back. I tried rebooting, I tried forcing Pleco to stop and I tried deleting its cache but it still crashes whenever I open it. The next option is to uninstall it, but considering it took me a long long time to install and download the gig and a half of add ons, I am loathe to do that. I really regret selecting that option.
 

caesartg

榜眼
Ok, I cleared all data and now I can use the app again but all my data is gone. Feeling pretty gutted to be honest.
 

mikelove

皇帝
Staff member
Yikes, sorry about that. (and that I didn't see this sooner) Did you try removing Pleco's permission to connect to AnkiDroid? That should have reverted it to its own flashcard system. (a corrupted permission could also be the reason why this started in the first place, actually)
 

caesartg

榜眼
Ah, Anki's "Advanced - Plugins - Enable AnkiDroid API" setting? I guess that was checked by default and I assumed when I saw permissions being mentioned elsewhere, this was either in Pleco (which I couldn't access) or in the MIUI phone settings/developer settings. I just replicated the original problem, and that would have fixed it.

I've got a 2 year old backup with 4000 custom cards but I think it's time to say farewell to my fevered old efforts and start afresh.
 

caesartg

榜眼
Just to add a note to this - my experience since disabling MIUI Optimizations and later reenabling then switching off developer mode seems to have resulted in all sorts of problems. Icons flicker, the graphics have changed, all my apps lost permissions and keep rerequesting them, I started getting lots of random notifications from Sogou keyboard (I ended up uninstalling it and had to download an uninstaller to get rid of it), my Skype started requesting permission to access the microphone, even though it had permission to do so (ended up deleting and reinstalling). These are just the problems I've encountered in the last day or so. My guess is MIUI has some kind of permission translation from Android to its handling and flicking the switch on and off screwed that up. I'm hoping MIUI 12 will put everything back to normal when it is released for my device in the next month or so and save me having to work out how to restore etc.

I suggest being very cautious about entering developer mode and changing the optimization setting on a Mi 8 on MIUI v11.0.8.
 

mikelove

皇帝
Staff member
Yeah, to be honest my current recommendation for Xiaomi users is 'flash your phone to an Android distribution other than MIUI' - there are just too many bugs these days, Huawei/Samsung and for that matter even other second-tier OEMs like Oppo/Motorola/LG seem to do a better job of not screwing up their firmware than Xiaomi does.

Xiaomi has always been philosophically more aggressive about pushing the envelope of Android forking than other OEMs, but I think in the last year or two MIUI has hit that 'mythical man-month' point of being too big/unwieldy to continue developing without sacrificing quality or massively increasing the size of their development team. (Microsoft hit it in the mid-'00s and then basically just imploded, Apple hit that point a few years ago and kind of went for a combination of lower quality / larger teams / scaled-back feature sets, Google has seemingly avoided the worst of that in Android by investing a ton of resources into completely isolating different bits of Android from each other so that the core OS remains small enough for a sensible-sized team to manage)
 
Last edited:
Top