kamwithk / ankiconnectandroid Goto Github PK
View Code? Open in Web Editor NEWUnofficial Ankiconnect for Android (i.e. for Yomichan)
License: GNU General Public License v3.0
Unofficial Ankiconnect for Android (i.e. for Yomichan)
License: GNU General Public License v3.0
Most of the time, when doing lookups, the Yomichan popup shows the loading bar on top indefinitely until I switch out of Kiwi (going to the home screen or another app). Once I do that, the request goes through and the Plus button shows up in the Yomichan popup.
I have battery optimization disabled for AnkiConnect, AnkiDroid, and Kiwi. I also “locked” each of them in the app switcher.
Device: OnePlus 9
Android version: 12
This might be OnePlus-specific — apparently it’s notorious for killing background apps. https://dontkillmyapp.com/oneplus
But the weird thing is that Kiwi itself seems to be the one having issues sending (or completing?) the request. Also, as far as I can tell, AnkiConnect itself is active.
I can provide any other info, just let me know.
Also glad to contribute a patch if needed, though I might need some hand-holding, as I haven’t written any Android code before.
Duplicates are not working in my case. I can even add two times the exact same card within a second. Ankidroid and ankiweb are detecting the duplicates. I'm using furigana as the "primary key" for filtering. It works fine with desktop ankiconnect. I tested to change the primary key as a constant string and the problem still occurs. I think somehow android ankiconnect is not getting information that card is a duplicate. Card is added instantly so there's no timeout or anything.
Hi!
In yomichan popup window there's no "+" sign to create an Anki card, even though yomichan says that he's connected to Anki.
It even has all the information about Anki decks and note types, so it's definitely connected.
If you go to the http://127.0.0.1:8765 it gives you the following error:
Error: java.lang.NullPoniterException : Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
Any ideas how to fix it? Thanks for help in advance.
Greetings!
My device: Onyx Boox Leaf 2 (android 11)
I have installed a Koreader plugin using this tutorial guide: https://github.com/Ajatt-Tools/anki.koplugin
Then I installed AnkiconnectAndroid, put http://localhost:8765/ in CORS Host settings, start service. When I press add to anki in Koreader, I get these errors:
Any solutions?
I discovered a weird thing that doesn't happen with the desktop ankiconnect app but happens with AnkiconnectAndroid.
With the addNote api, if I try to add a note and leave out any optional field, the api crashes with a pretty cryptic error message.
Here's a failed call:
{
"action": "addNote",
"version": 6,
"params": {
"note": {
"deckName": "reserve",
"modelName": "Japanese 2022 new accent note",
"fields": {
"Expression": "ユウキさんのお母さんは、いい人ですか。",
"Meaning": "ゆう‐き【勇気】\n<mark>ゆう‐き</mark>【<mark>勇気</mark>】<br />いさましい意気。物に恐れない気概。<span class=\"quote border border-dark rounded mr-3\">\n 「―をふるう」\n <span class=\"quote-actions\" data-quote=\"―をふるう\"></span>\n </span><span class=\"quote border border-dark rounded mr-3\">\n 「―がわく」\n <span class=\"quote-actions\" data-quote=\"―がわく\"></span>\n </span><br />⇒ゆうき‐づ・ける【勇気付ける】<br />⇒ゆうき‐りんりん【勇気{{zb93e}}{{zb93e}}】<br />",
"Audio": "",
"Focus": "勇気",
"Meaning2": "Is Yuki's mother a good person?"
//
// NOTE: a field is left out:
//, "Snapshot": ""
//
},
"tags": [
"hare"
],
"options": {
"allowDuplicate": true
},
"audio": [
{
"url": "https://receptomanijalogi.web.app/audio/bunpro/ユウキさんのお母さんは、いい人ですか。.mp3",
"filename": "hare_勇気_2023-01-03T08:45:36.052Z",
"fields": [
"Audio"
]
}
]
}
}
}
The response:
{
"result": null,
"error": "java.lang.IllegalArgumentException: Incorrect flds argument : ユウキさんのお母さんは、いい人ですか。\u001fゆう‐き【勇気】\n\u003cmark\u003eゆう‐き\u003c/mark\u003e【\u003cmark\u003e勇気\u003c/mark\u003e】\u003cbr /\u003eいさましい意気。物に恐れない気概。\u003cspan class\u003d\"quote border border-dark rounded mr-3\"\u003e\n 「―をふるう」\n \u003cspan class\u003d\"quote-actions\" data-quote\u003d\"―をふるう\"\u003e\u003c/span\u003e\n \u003c/span\u003e\u003cspan class\u003d\"quote border border-dark rounded mr-3\"\u003e\n 「―がわく」\n \u003cspan class\u003d\"quote-actions\" data-quote\u003d\"―がわく\"\u003e\u003c/span\u003e\n \u003c/span\u003e\u003cbr /\u003e⇒ゆうき‐づ・ける【勇気付ける】\u003cbr /\u003e⇒ゆうき‐りんりん【勇気{{zb93e}}{{zb93e}}】\u003cbr /\u003e\u001f\u001fIs Yuki\u0027s mother a good person?\u001fnull"
}
I can work around this issue by having any empty fields be set to the empty string.
When calling the store media file endpoint an error is received indicating a NullPointerException. I could not copy the text out of Kiwi Browser so I have attached a screenshot. The storage space used by AnkiConnect Android seems to go up so it looks like the file is persisting but the returned URL is null.
Edit: On debugging I found the following logs:
02-25 14:02:31.509 7581 7598 I AnkiDroid: Opening Collection Log
02-25 14:02:31.556 7581 7595 W AnkiDroid: CardContentProvider/ Could not create temporary media file.
02-25 14:02:31.556 7581 7595 W AnkiDroid: java.io.IOException: File name too long
02-25 14:02:31.556 7581 7595 W AnkiDroid: at java.io.UnixFileSystem.createFileExclusively0(Native Method)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:349)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at java.io.File.createTempFile(File.java:2007)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at com.ichi2.anki.provider.CardContentProvider.insertMediaFile(SourceFile:157)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at com.ichi2.anki.provider.CardContentProvider.insert(SourceFile:635)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at android.content.ContentProvider.insert(ContentProvider.java:1701)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at android.content.ContentProvider$Transport.insert(ContentProvider.java:330)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:168)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at android.os.Binder.execTransactInternal(Binder.java:1179)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at android.os.Binder.execTransact(Binder.java:1143)
02-25 14:02:31.556 7581 7595 W AnkiDroid:
02-25 14:02:31.556 7581 7595 W AnkiDroid: java.io.IOException: File name too long
02-25 14:02:31.556 7581 7595 W AnkiDroid: at java.io.UnixFileSystem.createFileExclusively0(Native Method)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:349)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at java.io.File.createTempFile(File.java:2007)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at com.ichi2.anki.provider.CardContentProvider.insertMediaFile(SourceFile:157)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at com.ichi2.anki.provider.CardContentProvider.insert(SourceFile:635)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at android.content.ContentProvider.insert(ContentProvider.java:1701)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at android.content.ContentProvider$Transport.insert(ContentProvider.java:330)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:168)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at android.os.Binder.execTransactInternal(Binder.java:1179)
02-25 14:02:31.556 7581 7595 W AnkiDroid: at android.os.Binder.execTransact(Binder.java:1143
which seems fixable. I will work on a fix.
Hi, amazing app, thank you. With this you can get the full Japanese reading experience on mobile for the first time. My only issue is that every time I mine a card, I get a window that says:
2 errors occurred:
Whatever these errors are, they don't stop the app from working, and I can dismiss the window by just tapping outside of the Yomichan pop-up. So it's not a big deal, but thought I would report it. It'd look a bit cleaner without any error messages, after all ;)
Within the same deck if you have different note types/models it doesn't seem to check for duplicates within all the note types/models even if the yomichan/anki option -> 'Check for card duplicates' and -> 'Check for duplicates across all models' is selected.
Hello,
I was trying to get this to work and am running into an issue. On step 6 of the install guide it says to configure Yomichan for sentence mining. When I do this, I get the error below;
Additionally, no deck formats appear despite having multiple deck card formats available.
Any help? Is there some settings I missed that might cause this?
Thank you!
Yomichan status says it is connected with Anki Integration without any problem.
I can also use Yomichan in Kiwi Browser and have configured the card format.
But the add expression button is greyed out regardless.
Help for guidance. (Anyways I cannot find your discord user)
Hi once again,
I still have the same issue with the duplicates card. It seems like there was a new release that should've fixed the problem but it didn't. I couldn't find you're discord on the readme. If you put you're discord in the readme I can send you the config json that I am using in yomichan on my phone with kiwi browser.
If I can manage to reach you, I would have some questions on the project and maybe I could fix it on my own if you don't see any issues with the setup etc..
Thanks in advance,
This Ankiconnect Android apk is amazing .Beside yomichan,there is another extension which is simple and easy use,open for multiple languages :online dictionary helper (https://chrome.google.com/webstore/detail/online-dictionary-helper/lppjdajkacanlmpbbcdkccjkdbpllajb?hl=en) . It support Ankiconnect to localhost ,if this apk can have minor fix to support that extension ,that will definately have more and popular use.Thanks in advance!
How can I change Forvo JP to Chinese? Please help me :"<
For some reason, when reviewing #31 and #28, I didn't realize that the same media-handling logic was pretty much implemented in two separate ways. A future version of ZXY101's mokuro fork requires updateNoteFields
and url
to work, and merging the logic of the two would be a simple way to support this.
@sp3ctum @Twinov As of writing this issue, I'm currently working on doing exactly this. Would y'all be interested in reviewing the PR whenever it comes?
Using a galaxy s7 fe tablet, i do not see or know how to install it. The guide you give is very limited. Downloaded the zip. But how do i install you give little to information on this matter.
How do i install it? All it says install, how do install 3rd party apps? Please give more instructions to it. I go to files extract it, ankidroid can't open it either. Please give more a more guided instructions.
Hi, I'm working on my hobby project which is a Japanese web dictionary called hare: https://github.com/sp3ctum/hare
It's nothing special but I use it in my own workflow. I'd like to add support for anki connect as well as anki connect android in order to quickly add cards when I'm reading.
Anki connect allows customizing the CORS origin list in its config, here is an example:
{
"apiKey": null,
"apiLogPath": null,
"ignoreOriginList": [],
"webBindAddress": "127.0.0.1",
"webBindPort": 8765,
"webCorsOriginList": [
"http://localhost",
"https://sakura-paris.org"
]
}
https://sakura-paris.org is where I run my dictionary. Without the added configuration, all requests are blocked by chrome because they target another host. This is what it looks like:
But after this configuration has been saved, I can access the service from chrome.
I'll start by working on anki connect desktop but I understand AnkiConnectAndroid uses the same api (roughly) so I think I might be able to support both. This, I imagine, is what yomichan does as well.
Do you think it could be possible to add support for configurable CORS origins? I could maybe submit a PR for this but I'm not exactly sure how to do it yet.
Device: Boox Nova Pro 7.8
Android: 6.0.1
Message: "Unfortunately, Ankiconnect Android has stopped."
This is unfortunate because everything else, including Kiwi Browser, Yomichan, and AnkiDroid work with this device.
I have had some time to play with ankiconnect card adding with my hare dictionary project. I have the addNote api working for the desktop ankiconnect. With that I am able to add a note and download an audio file which is then added to the note. For this I am using the following:
{
"action": "addNote",
"version": 6,
"params": {
"note": {
"deckName": "reserve",
"modelName": "Japanese 2022 new accent note",
"fields": {
"Expression": "これは、ユウキさんのお母さんですか。",
"Meaning": "ゆう‐き【勇気】\n<mark>ゆう‐き</mark>【<mark>勇気</mark>】<br />いさましい意気。物に恐れない気概。<span class=\"quote border border-dark rounded mr-3\">\n 「―をふるう」\n <span class=\"quote-actions\" data-quote=\"―をふるう\"></span>\n </span><span class=\"quote border border-dark rounded mr-3\">\n 「―がわく」\n <span class=\"quote-actions\" data-quote=\"―がわく\"></span>\n </span><br />⇒ゆうき‐づ・ける【勇気付ける】<br />⇒ゆうき‐りんりん【勇気{{zb93e}}{{zb93e}}】<br />",
"Audio": "",
"Focus": "勇気",
"Meaning2": "Is this Yuki's mother?",
"Snapshot": ""
},
"tags": [
"hare"
],
"options": {
"allowDuplicate": true
},
"audio": [
{
"url": "https://receptomanijalogi.web.app/audio/bunpro/これは、ユウキさんのお母さんですか。.mp3",
"filename": "hare_勇気_2023-01-03T08:29:48.268Z",
"fields": [
"Audio"
]
}
]
}
}
}
With AnkiconnectAndroid it seems the params.note.audio
thing is ignored. If this is this by design, I'm fine with it. I think I can switch to using the storeMediaFile api and get the same result with two api calls.
May I ask what license you put your app under? You probably only forgot to declare it. If unsure, maybe pick a FOSS one that's approved by OSI/FSF? You can find a list here. Thanks!
Currently, only one value is allowed. Ideally, we should be able to support multiple sites, which means we will have to read the origin header of the incoming request and filter accordingly.
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.
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)
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.
My scanner got some new checks in January, and on today's update of your app reported:
! repo/com.kamwithk.ankiconnectandroid_13.apk declares sensitive permission(s):
android.permission.READ_EXTERNAL_STORAGE android.permission.SYSTEM_ALERT_WINDOW
! repo/com.kamwithk.ankiconnectandroid_13.apk contains signature block blobs: 0x504b4453 (DEPENDENCY_INFO_BLOCK; GOOGLE)
Could you please clarify what those permissions are needed for? As for that DEPENDENCY_INFO_BLOCK
, that's easily avoided:
android {
dependenciesInfo {
// Disables dependency metadata when building APKs.
includeInApk = false
// Disables dependency metadata when building Android App Bundles.
includeInBundle = false
}
}
For some background: that BLOB is supposed to be just a binary representation of your app's dependency tree. But as it's encrypted with a public key belonging to Google, only Google can read it – and nobody else can even verify what it really contains.
Thanks in advance!
This issue is to open a discussion on whether the project should have a source code formatter taken into use.
What benefits could it bring?
A formatter typically has the following functions:
Thus adding a formatter would need the following:
I have previously worked with a java formatter called google-java-format which has good plugins for IDEA, Android Studio (I have no personal experience using it with Android Studio) and I think one developer used it with Eclipse. The formatting style in this formatter is not configurable at all, you can literally change nothing, I think. This means it's extremely opinionated but also very easy to set up.
The tag icon next to an added word is not displayed in cases where it would be appropriate to be displayed as per my experience with the pc version of yomichan/anki connect.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.