AnkiconnectAndroid
AnkiconnectAndroid copied to clipboard
Notes Info API isn't implemented causing MalformedJsonException when updating card image through mokuro files
When using the HTML files provided by Mokuro (not to be confused with the separate Mokuro Reader app) and enabling Anki integration in the advanced settings, I can successfully create new cards by pressing the green button in the Yomibaba/Yomitan pop-up but I can't add a picture to the card.
Screenshot of the advanced settings
Looking at the dev console of the Kiwi Browser mobile app that I use, I can see the following stack trace when I press "Complete":
Uncaught (in promise)
com.google.gson.stream.MalformedJsonException:
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 14 path $com.google.gson.stream.MalformedJsonException:
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 14 path $
at
com.google.gson.JsonParser.parseReader(JsonParser.java:66)
at
com.google.gson.JsonParser.parseString(JsonParser.java:47)
at
com.kamwithk.ankiconnectandroid.routing.AnkiAPIRouting.findRouteHandleError(AnkiAPIRouting.java:101)
at
com.kamwithk.ankiconnectandroid.routing.APIHandler.chooseAPI(APIHandler.java:33)
at
com.kamwithk.ankiconnectandroid.routing.RouteHandler.get(RouteHandler.java:70)
at
fi.iki.elonen.router.RouterNanoHTTPD$DefaultStreamHandler.post(RouterNanoHTTPD.java:100)
at
fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(RouterNanoHTTPD.java:386)
at
fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
at
fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
at
[...]
at java.lang.Thread.run(Thread.java:764)
Caused by:
com.google.gson.stream.MalfromedJsonException:
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 14 path $
at
com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1597)
at
com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1404)
at
com.google.gson.stream.JsonReader.doPeek(JsonReader.java:542)
at
[...]
(I didn't find a way to copy the contents of the error from the Kiwi browser console so this was transcribed by hand on the basis of the screenshots in the spoiler)
Screenshots of error
I made sure to open AnkiDroid, start the Ankiconnect (v1.12) service and added https://mokuro.moe
to the CORS host
in the settings. I also disabled battery optimizations on the Ankiconnect app and the Kiwi Browser app.
I tested doing the exact same steps on desktop (open the same web page, highlight the same word, create the card, add an image via mokuro) and it worked fine so it is not as if the mokuro file is serving bad JSON data that Ankiconnect can't do anything about, since it seems like the desktop version of Ankiconnect has no issue with the commands received from mokuro.
You should go to the Network tab in the browser dev tools and click on the request, then look at the json and make sure it's correctly formatted or post it here.
I'm seeing this payload in the POST request:
{
action: "notesInfo",
version: 6,
params: {
notes: [<ID obtained from response of previous `findNotes` query>]}
}
Judging from the existence of #46, I'm guessing that Ankiconnect does not support the notesInfo
action and this might be the source of my issue?
Yeah that's correct, notesInfo isn't implemented yet.