Closed squishygian closed 10 months ago
OK, I went into the anki settings in koreader and changed the deckname so it matched the one I have in ankidroid, now there is a different error that says “couldnt get model ID”
Sorry I didn’t mean to close the issue this is my first time using github so the UI is a little confusing
Update: When the android ankiconnect app is off it will store the notes offline and say “unable to reach anki connect, connection refused” as opposed to the previous error, so it does seem to be communicating with ankiconnect on some level.
The bunch of other random words aren't coming from this plugin, that's a stacktrace coming from that ankiconnect implementation you're using. I've never seen this before. Considering the "Couldn’t Get Deck ID" was fixed by using the correct deck name in your config, I assume "couldnt get model ID" means you also have the wrong model name in your config.
The plugin normally should just work on android, as long as you have some way to connect with Anki. That custom ankiconnect implementation should work, although I remember there was an issue with it before (https://github.com/KamWithK/AnkiconnectAndroid/issues/47) that doesn't seem to have been addressed yet
The bunch of other random words aren't coming from this plugin, that's a stacktrace coming from that ankiconnect implementation you're using. I've never seen this before. Considering the "Couldn’t Get Deck ID" was fixed by using the correct deck name in your config, I assume "couldnt get model ID" means you also have the wrong model name in your config.
The plugin normally should just work on android, as long as you have some way to connect with Anki. That custom ankiconnect implementation should work, although I remember there was an issue with it before (KamWithK/AnkiconnectAndroid#47) that doesn't seem to have been addressed yet
Thank you for the resourceful reply! Just a few questions I’m a little confused on
1: There shouldn't be anything preventing you from using the normal ankiconnect implementation, this being the addon on the desktop Anki version (https://ankiweb.net/shared/info/2055492159) The obvious downside with that is that you need to have your PC running anki to be able to connect to it and sync your notes. The koplugin stores notes locally for this reason, so you can sync occasionally and don't need to have your PC running all the time.
2: No idea, I haven't heard back from the one guy that tried doing this. I've never tried it myself. It claims to just be another implementation of the ankiconnect addon so it should work
3: in Anki each note has an associated model which determines what fields are on your note. You can check in Anki itself, in the menu: Tools - Manage Note Types. You need to provide the name of the note type you want, and the word_field
, def_field
, etc. should refer to fields of this note type
1: There shouldn't be anything preventing you from using the normal ankiconnect implementation, this being the addon on the desktop Anki version (https://ankiweb.net/shared/info/2055492159) The obvious downside with that is that you need to have your PC running anki to be able to connect to it and sync your notes. The koplugin stores notes locally for this reason, so you can sync occasionally and don't need to have your PC running all the time.
2: No idea, I haven't heard back from the one guy that tried doing this. I've never tried it myself. It claims to just be another implementation of the ankiconnect addon so it should work
3: in Anki each note has an associated model which determines what fields are on your note. You can check in Anki itself, in the menu: Tools - Manage Note Types. You need to provide the name of the note type you want, and the
word_field
,def_field
, etc. should refer to fields of this note type
Hello, sorry for the late reply, I did not realize I could connect through my pc, I totally misinterpreted the instructions, and to be honest Im still a but confused by them so I was wondering if you could help me answer these questions:
I have the plugin up and running on koreader but it’s not able to send notes to anki on my computer even when I plug it in, I installed ankiconnect on my computer and changed the webbindaddress to 0.0.0.0 as instructed, the next step says to replace the destination path, I’m assuming this is just for the installation of the plugin? I see the destination path has a website though what is that for?
What do I do with the ssh server and ip address information from step 3?
What is that line of code in step 3, do I need to add that to anki connect or something?
Thank you
No need to worry about step 2 and step 3, they are instructions to install the plugin on your desktop (since you can use KOReader on desktop too), and on your e-reader device, which you already managed to do just fine.
You just need to configure the plugin correctly so it can reach AnkiConnect, so that's the url
in your settings, that should be either localhost (when you're running AnkiConnect on your android device directly) or the local IP of your PC itself (when running Anki on your PC with the ankiconnect addon).
Judging by the errors you showed earlier ankiconnect-android was working okay, you just had the wrong deck- and model name in your config
I changed it to the correct deckname and now I get this error
Actually I don’t think it has anything to do with the deckname, even if I change it to a non existing deck it crashes everytime I try to add to anki on my koreader app
OK sorry, I hadn’t changed the deck type to the one I wanted (basic) here is the new crash report
I should also add that I’m trying to add English words, I don’t know what affect that might have
Sorry, I have no idea what those errors are about, you mean KOreader opens fine, the plugin loads, but once you click the button it shows that error?
Can you upload your crash.log? It's a log file that's normally somewhere in koreader's root directory, posting snippet from koreader docs below:
/mnt/private/koreader
for Cervanteskoreader/
directory for Kindle.adds/koreader/
directory for Koboapplications/koreader/
directory for PocketbookNot sure how you managed to get from the useful errors to this hard crash, I'm not following which changes you made exactly anymore. Might be worth a try to reinstall the plugin completely. The errors you got when opening this issue were simply related to your config having the wrong deck and model name, I can't tell what's going wrong anymore now
I should also add that I’m trying to add English words, I don’t know what affect that might have
That should not be a problem at all
OK I apologize, I neglected to add the https:// before the localhost 8765 on the anki koreader plugin settings on my device, I fixed that and no longer am experiencing crashes but I am still unable to connect so I will continue to troubleshoot
Make sure you have that android-ankiconnect thing running if you're gonna use localhost, it was connecting fine before
I’m just going to stick with how it was intended to be used with the PC as the host and Japanese vocab for now because doing it from the ereader with the apps is a whole different can of worms and I’m still not sure if it’s even possible, I referenced the other closed articles and changed my url in the koreader plugin to my computers ipv4, now I’m getting a message that says: “Unable to reach ankiconnect invalid host: ‘nil’ stored offline”
For what it's worth, I think you were pretty close to getting it working with the android ankiconnect implementation here. You managed to connect to it fine, the only thing that seemed to be wrong was the model name in your config which is an easy fix.
I’m just going to stick with how it was intended to be used with the PC as the host and Japanese vocab for now because doing it from the ereader with the apps is a whole different can of worms and I’m still not sure if it’s even possible
It's intended to be used with the ankiconnect REST api, on some devices the only option is connecting to your PC's ankiconnect, but that custom implementation should work just as well.
I referenced the other closed articles and changed my url in the koreader plugin to my computers ipv4, now I’m getting a message that says: “Unable to reach ankiconnect invalid host: ‘nil’ stored offline”
that sounds like your url is incorrect still, I'd suggest trying if you can 'talk' to ankiconnect on your browser from the built-in terminal to see if that works: https://github.com/Ajatt-Tools/anki.koplugin/issues/2#issuecomment-1489214507
OK so I guess I will attempt with the apps because it would be way more convenient, I don’t think it’s connecting anymore though because I’m getting a message that says: “unable to reach anki connect wantread stored offline”
Did you set the url back to http://localhost:8765 ?
Also make sure it's http and not https
Oh my god I apologize again I am so tech illiterate 😭 one “s” at the end of http was causing a meltdown, thank you for your infinite patience with me, OK I’m back at the couldn’t get model ID error, so I downloaded a code editor to edit config.lua, I changed the deckname to the correct one, what else do I need to do in there?
change modelName to whatever model you want it to use. What note type do you use to make cards usually? Just pick that, if it's the plain flashcard one it's just called 'Basic' by default
So the Default deck in ankidroid uses “Basic (and reversed card)” I tried inputting both “Basic” and “Basic (and reversed card)” and I’m still getting the couldnt get model id error
You're confusing deck and model I think, deck is the name of the deck your cards go in, model is the type of note you're storing in that deck
I don’t think I am? I attached an image of my config.lua
Oh fuck you're right, sorry
That looks good to me :thinking: Another thought, you mentioned earlier:
OK, I went into the anki settings in koreader and changed the deckname so it matched the one I have in ankidroid, now there is a different error that says “couldnt get model ID”
So you actually installed that patch then to get to the menu? Can you check if it actually shows the correct deck and model name in there too? It actually stores whatever you set in there in a different place from the actual config.lua
you're editing now, and that place takes precedence.
I put a note about that at the bottom here https://github.com/Ajatt-Tools/anki.koplugin?tab=readme-ov-file#edit-configuration-within-koreader
Yes I deleted the .lua file in settings, I even tried a new deck with basic with no luck :( I’ll just try the PC route again
Ok I have another idea, I took a look at that ankiconnect implementation:
In here it is asking for the model name, passing in what I assume to be the correct one. However, it also passes in data.size()
, this is a list of all fields you're trying to add on your note. This means it will not consider any model as valid if the amount of fields on it are less than the amounts of fields you're trying to save on it (This is different from the standard ankiconnect!)
The Basic note type only has 2 fields (back and front), but this plugin by default tries to save a few more, namely all the fields listed here https://github.com/Ajatt-Tools/anki.koplugin?tab=readme-ov-file#features, that's the stuff below 'NOTE FIELD CONFIGURATION OPTIONS' in config.lua
Since you're trying to use the Basic note template, I guess you only really want the word (word_field
) and the definition (def_field
). So if you remove all the other fields (you can just delete these from the config completely), there should only be these 2 fields and then it might work.
I tried doing that and no luck, it just won’t recognize the model id for whatever reason, I’m still getting the nil host error on my pc, I tried the terminal and it didn’t work, here are all my settings:
My config.lua settings: (same in the anki.plugin koreader settings)
url= (My computer’s IPv4 address)
deckName = "Anki test",
modelName = "Basic",
My settings on the ankiconnect desktop app:
"apiKey":null, "apiLogPath": null, "ignoreOriginalList: [], "webBindAddress": “0.0.0.0” "webBindPort": 8765, "webCorsOrigintist "http://localhost”
What the terminal showed:
I tried doing that and no luck, it just won’t recognize the model id for whatever reason, I’m still getting the nil host error on my pc, I tried the terminal and it didn’t work, here are all my settings:
My config.lua settings: (same in the anki.plugin koreader settings)
url= (My computer’s IPv4 address)
deckName = "Anki test",
modelName = "Basic",
My settings on the ankiconnect desktop app:
"apiKey":null, "apiLogPath": null, "ignoreOriginalList: [], "webBindAddress": “0.0.0.0” "webBindPort": 8765, "webCorsOrigintist "http://localhost”
What the terminal showed:
You didn't run the command though, curl 127.0.0.1:8765
(replace 127.0.0.1 with your local IP address) which should print the 'AnkiConnect' string. Since this e-reader runs android, does it come with a browser too? If so, you can just go to the url http://127.0.0.1:8765 and see if it prints anything.
I tried doing that and no luck, it just won’t recognize the model id for whatever reason, I’m still getting the nil host error on my pc, I tried the terminal and it didn’t work, here are all my settings:
I'd like you to post the crash.log after enabling debug logging (in settings - More tools - Developer options - Enable debug logging, note that this setting only shows up in the koreader filemanager, not while having a document open)
If you try to save a note then it should print the actual message it's sending to ankiconnect. If you could do that for both the PC and android ankiconnect versions it might contain a hint as to what's wrong
I want to provide you with an important update…….ITS ADDING CARDS ON THE ANKIDROID APP ANYTHING IS POSSIBLE!!!! albeit the cards just say “null” on the front and back 😭 I think your suggestion of deleting everything except for those 2 fields worked, I must’ve left a bracket or something behind by accident the first time, we’re almost there I can feel it 😬, what should I do next?
Just an uneducated guess, could this possibly have to do with the values for the word field and glossary field? i.e. VocabKanji and VocabDef? Should I try changing these to something else?
YESSSSSSS!!!! IT WORKS NOW I JUST HAD TO CHANGE THOSE TWO VALUES TO “FRONT” and “BACK” THANK YOU SO MUCH SIR YOU ARE A GENIUS YOU HAVE NO IDEA HOW MUCH TIME THIS WILL SAVE ME HAPPY NEW YEARS TO YOU SIR
:partying_face: glad you got it working in the end, that word_field
and def_field
indeed need to refer to the names of the fields on your note where you want them to go to, but looks like you figured that out
🥳 glad you got it working in the end, that
word_field
anddef_field
indeed need to refer to the names of the fields on your note where you want them to go to, but looks like you figured that out
Another exciting update!! This might be obvious to more advanced Anki users but going off of what you said earlier I wanted to see if it was possible to use all the features by adding more fields to the Basic card type, and it is! You just need to go into ankidroid and create the fields you want with the correct names, then edit your card type, doesn’t matter what type as long as it’s the one referenced in the code, and manually add the field types in and it should work!! Just wanted to leave this here in case anyone else using this on an android platform was curious
Hello, I am trying to run this on my BOOX Palma but I’m not sure if it’s compatible or not, the Palma’s OS is Android 11 and I currently use the Ankidroid and Ankiconnect android apps along with the Yomitan broswer extension to automatically create flashcards while using my regular browser. I really needed something for when I’m reading though so when I saw this I was pretty excited and downloaded it and was able to install it to Koreader but unfortunately whenever I select the “add to anki” button after highlighting a word, I get an error that says “Couldn’t Synchronize Note, Couldn’t Get Deck ID” and then a bunch of other random words(see picture below) I just want to know if it’s even possible to use this plugin on Android so I don’t waste my time ripping my hair out trying to figure this out because it would be a huge lifesaver for me as I currently create anki cards by hand for all my reading vocab, thank you so much!