Skip to content

KOReader Anki plugin add card support #89

@mallomar

Description

@mallomar

Description:

AnkiConnect Android v1.15 returns malformed JSON when the KOReader Anki plugin attempts to add cards, but works correctly with Yomichan. This suggests an incompatibility with how AnkiConnect Android handles certain AnkiConnect API requests.

Environment:

  • AnkiConnect Android version: 1.15
  • AnkiDroid version: 2.22.3
  • Android version: 15
  • Device: Samsung Galaxy S23 FE
  • KOReader version: 2025.08

Steps to Reproduce:

  1. Install AnkiConnect Android v1.15
  2. Configure KOReader Anki plugin to connect to http://localhost:8765
  3. Set up a simple card profile (deck: "Vocabulary Builder", note type: "Basic (and reversed card)-31325")
  4. Attempt to test the connection or add a card from KOReader

Expected Behavior:
KOReader should successfully add cards to AnkiDroid via AnkiConnect Android, similar to how Yomichan successfully adds cards.

Actual Behavior:
Connection test fails with malformed JSON error. The error occurs even with the simplest card template (no context field, just word and definition fields).

Error Log:

Failed to connect to 'http://127.0.0.1:8765':
com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 14 path $
com.google.gson.JsonSyntaxException: 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:106)
    at com.kamwithk.ankiconnectandroid.routing.APIHandler.chooseAPI(APIHandler.java:33)
    at com.kamwithk.ankiconnectandroid.routing.RouteHandler.getRouteHandler(RouteHandler.java:73)
    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.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
    at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
    at java.lang.Thread.run(Thread.java:1119)
Caused by: com.google.gson.stream.MalformedJsonException: 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 com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
    at com.google.gson.JsonParser.parseReader(JsonParser.java:61)
    ... 11 more

Additional Context:

  • Yomichan browser extension successfully adds cards to the same deck via AnkiConnect Android
  • Both URLs tested (http://localhost:8765 and http://127.0.0.1:8765) produce the same error
  • The "Vocabulary Builder" deck exists in AnkiDroid
  • The note type "Basic (and reversed card)-31325" exists in AnkiDroid
  • Error occurs with minimal card configuration (only word and definition fields, no context)

The KOReader Anki plugin developer noted that AnkiConnect Android should work since it implements the AnkiConnect API (see this comment). Since Yomichan works but KOReader doesn't, this suggests AnkiConnect Android may be handling certain API request formats differently.

Note: The error message suggests the JSON being parsed has an issue at "line 1 column 14 path $", which indicates the malformed JSON is in AnkiConnect Android's response to KOReader's request, not in KOReader's request itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions