ankimini

459 views
Skip to first unread message

Brian Bush

unread,
Oct 19, 2009, 1:38:13 PM10/19/09
to Anki Android
I know ankidroid is java based, but does anyone know of getting anki
mini to run on android?
I am aware of the python version issue (and that ASE is not python 2.6
- or anywhere close).

Thanks,
Brian

Damien Elmes

unread,
Oct 19, 2009, 11:40:25 PM10/19/09
to anki-a...@googlegroups.com
ankimini on java was held up by sqlite not working in python. I think
it has subsequently been fixed, but I don't know if anyone has
investigated it further.

Nicolas Raoul

unread,
Oct 20, 2009, 12:34:15 AM10/20/09
to anki-a...@googlegroups.com
I am not aware of anyone getting anki mini to run on android.
If anyone managed to run something or just tried to, please share your experience :-)

Cheers,
Nicolas Raoul.

Brian Bush

unread,
Oct 20, 2009, 3:56:53 PM10/20/09
to Anki Android
I am getting an adroid phone soon (shipped already) and will see what
I can do.
I found notes of getting 2.6 working on android (http://
groups.google.com/group/android-scripting/browse_thread/thread/
6a2fcc058fc7a5b1).
So ankimini requires python2.6, sqlite, sqlalchemy.
Anything else?

Brian Bush

unread,
Oct 25, 2009, 1:59:58 AM10/25/09
to Ankidroid
I now have ankimini running on android ASE (r13), pretty nice, but it
took some source juggling to get the path issues to work. I will post
a write up later here and on my blog. The only outstanding issue is
that I don't have audio working. Can't figure out the PLAY_COMMAND on
android for audio support. More later.

Nicolas Raoul

unread,
Oct 25, 2009, 2:21:51 AM10/25/09
to anki-a...@googlegroups.com
Wonderful!

Does it mean that ASE has all of the libraries libanki needs?
Can it be packaged as an normal Android application, or does it
require anything tricky that can not be done with an APK deployment?

Does it require anything that a normal user would not do? For instance
ankimini requires users to jailbreak their iPhone.

I'm really looking forward to your write up :-D
Cheers!
Nicolas.

Damien Elmes

unread,
Oct 25, 2009, 7:01:47 AM10/25/09
to anki-a...@googlegroups.com
On Sun, Oct 25, 2009 at 2:59 PM, Brian Bush <brian...@gmail.com> wrote:
>
> I now have ankimini running on android ASE (r13), pretty nice, but it
> took some source juggling to get the path issues to work. I will post
> a write up later here and on my blog. The only outstanding issue is
> that I don't have audio working. Can't figure out the PLAY_COMMAND on
> android for audio support. More later.

You mailed me directly about this too, but it's better left on the
list. The problem with the iPhone OS 3.0+ was that the command line
program was broken in an API change. When the program was fixed, the
sound started working again.

If Android has no command line audio player, we'll either need to
write one, or redefine/rewrite the play audio routine to call other
python code.

Brian Bush

unread,
Oct 25, 2009, 12:42:42 PM10/25/09
to Ankidroid
No Jailbreaking or compiling code like action is required. All with
the ASE distro.
Not all libraries are included, so I had to install source for
simplejson and sqlalchemy.
I have a short cut on the desktop to launch ankimini (under ASE), but
the whole process is probably not for the average user unless we make
mods to the ankimini distro. The biggest problems are the lack of a
user home and the paths required to run main.py in ankimini. It really
was only a few hours of toying.
Brian

Brian Bush

unread,
Oct 25, 2009, 12:56:58 PM10/25/09
to Ankidroid

How to get ankimini working on Android (1.5, cupcake)

Requirements: Android phone, simplejson, sqlalchemy, text editor, no
fear of editing scripts.

Overview: Download required libraries, interpreter. Modify ankimini
slightly in path handling.

1. Download and Install ASE r13,
Go to: http://code.google.com/p/android-scripting/
from the device browser and download directly to the phone.
Install, and add a python 2.6 interpreter.

2. Plug in device to host computer via USB and mount device. Should be
automatic.

My mount point was /media/disk, this might be different for you.

3. Download simplejson ,untar and install
wget http://pypi.python.org/packages/source/s/simplejson/simplejson-2.0.9.tar.gz
tar zxvf simplejson-2.0.9.tar.gz
mv simplejson-2.0.9/simplejson /media/disk/ase/scripts/

4. Download sqlalchemy, untar and install
wget http://prdownloads.sourceforge.net/sqlalchemy/SQLAlchemy-0.5.6.tar.gz?download
tar zxvf SQLAlchemy-0.5.6.tar.gz
mv SQLAlchemy-0.5.6/lib/sqlalchemy/ /media/disk/ase/scripts/

5. Download and install Anki (libanki), basically copy libanki/anki to
/media/disk/ase/scripts/
cp -r libanki/anki/ /media/disk/ase/scripts/

6. Copy main.py in ankmini distro into /media/disk/ase/scripts/

7. Change ankmini (main.py) ANKIMINI_PATH to be
ANKIMINI_PATH=os.path.join("/sdcard",".anki")

(There is no home directory for the user, unfortunately we have a
fixed path, but it won't change. Basically the /sdcard root is the
user directory since it is the only part of the filesystem that you
have access to).

8. Create a directory in root of SD card. I called mine .anki. Thus
the directory is /media/disk/.anki

9. Copy anki deck (and associated media if used) to use to this .anki
directory

10. Copy ankimini-config.py to /media/disk/.anki/.

11. Edit ankimini-config.py file

DECK_PATH='/sdcard/.anki/kanji.anki'
SERVER_PORT=8000
PLAY_COMMAND='play'
SYNC_USERNAME=xxx
SYNC_PASSWORD=xxx

12. Open up ASE, click on main.py and this will launch the server. You
should see no exceptions or errors.

13. Go to the browser and go to 127.0.0.1:8000 (somehow localhost is
not recognized).

(You can also create a short cut to your desktop for the main.py
script)


Question: Is it ok for the server to be killed? I know the sqlite db
has journaling, just wondering since on android the os will kill your
app for you if it needs memory.

Damien Elmes

unread,
Oct 25, 2009, 1:13:32 PM10/25/09
to anki-a...@googlegroups.com
> 7. Change ankmini (main.py) ANKIMINI_PATH to be
> ANKIMINI_PATH=os.path.join("/sdcard",".anki")
>
> (There is no home directory for the user, unfortunately we have a
> fixed path, but it won't change. Basically the /sdcard root is the
> user directory since it is the only part of the filesystem that you
> have access to).

Why not define a HOME instead?

> Question: Is it ok for the server to be killed? I know the sqlite db
> has journaling, just wondering since on android the os will kill your
> app for you if it needs memory.

Killing the app or shutting down your device should be safe, provided
Android's fsync() is reliable.

Daniel Svärd

unread,
Oct 25, 2009, 2:09:08 PM10/25/09
to anki-a...@googlegroups.com

So what does this all mean for us? Are we just wasting our time
developing Ankidroid now that the functionality is already in
Ankimini?

Regards,
Daniel

Andrew

unread,
Oct 25, 2009, 2:33:08 PM10/25/09
to anki-a...@googlegroups.com
I don't think so. I thought the long term goal was to share as much Anki code as possible, but maintain an Android UI.

To be honest, the 'whiteboard' feature was the main reason I started my initial implementation (where implementation = horrible hack :) of Anki. It has helped me a lot with Japanese Kana. While I may not have much need for it at the moment, when I decide to try my hand at Kanji, I'll need a flashcard system that supports drawing.

We've also had questions about integration with Python for a while. We obviously want a smooth install process for most users (meaning a simple install through the market), so we've had a few separate efforts between Java and Python, with the hope that we eventually converge on a solution that takes advantage of Damien's work while providing a simple Android experience.

Now would be a good time to debate this. Keep in mind I don't actively add code, so my opinion matters very little :)

I think the next cool thing to do would be to try to use the native development kit to somehow include Python in the main apk. If possible, installing it on to the sdcard (including all of the libs and scripts, and even Python itself, if possible). While this would be bulky, it would be the best medium-term solution to code reuse and Android UI. ASE is open source, so a lot of the work is probably done for us already.

2009/10/25 Daniel Svärd <daniel...@gmail.com>

Casey Link

unread,
Oct 25, 2009, 2:49:53 PM10/25/09
to anki-a...@googlegroups.com
On Sun, Oct 25, 2009 at 2:33 PM, Andrew <andre...@gmail.com> wrote:
> I don't think so. I thought the long term goal was to share as much Anki
> code as possible, but maintain an Android UI.

Ditto

> We've also had questions about integration with Python for a while. We
> obviously want a smooth install process for most users (meaning a simple
> install through the market), so we've had a few separate efforts between
> Java and Python, with the hope that we eventually converge on a solution
> that takes advantage of Damien's work while providing a simple Android
> experience.

I wholeheartedly agree with this. I'm against the idea of maintaining
a separate Java SRS in parallel to Anki. Out of all of us Damien is
the only proven reliable constant, so I think it makes sense to depend
on his code as much as possible. Otherwise we could end up with a
really great half implemented SRS on Java, or a great implementation
now.. but a couple years from now when no one is available to fix the
Java library and Damien has matured libanki even more we'd be stuck
with a poor Anki imitation.

Of course I don't think it is possible to bundle everything we need in
the APK at the moment, nor do we know if it ever will be, so working
on a java version of libanki could be the only solution.

> Now would be a good time to debate this. Keep in mind I don't actively add
> code, so my opinion matters very little :)

The same goes for me. Take everything I say here with the knowledge
that I can't actively contribute for the time being.

> I think the next cool thing to do would be to try to use the native
> development kit to somehow include Python in the main apk. If possible,
> installing it on to the sdcard (including all of the libs and scripts, and
> even Python itself, if possible). While this would be bulky, it would be the
> best medium-term solution to code reuse and Android UI. ASE is open source,
> so a lot of the work is probably done for us already.

This would be nice, but I suspect it is very difficult, if not nigh
impossible at the moment.

Just FYI: Everyone knows that iAnki works with android? So for some
this will be fine until the python java branches converge.

Casey

Brian Bush

unread,
Oct 25, 2009, 3:41:27 PM10/25/09
to Ankidroid
> > I don't think so. I thought the long term goal was to share as much Anki
> > code as possible, but maintain an Android UI.

One way to use the current java UI would be to talk to ankimini server
with JSON, then the UI could be more consistent with the platform.
Then ankimini would only need to be changed to send/receive JSON
(versus HTML) and we would gain all the benefits of the anki platform.
Just my two cents.

There is still work to be done to get anki working completely on the
android platform. Sound is my main concern now, since I use it a lot
in my Japanese studies.

Brian

On Oct 25, 11:49 am, Casey Link <unnamedramb...@gmail.com> wrote:

Damien Elmes

unread,
Oct 25, 2009, 3:50:11 PM10/25/09
to anki-a...@googlegroups.com
does webkit on android support html5 audio tags? if so, that would be
very easy to implement.

Brian Bush

unread,
Oct 25, 2009, 3:58:22 PM10/25/09
to Ankidroid
No according to Dan..., but this was from back in March.
From: Dan Morrill <morri...@google.com>

We do aim to include features from HTML5 over time, but currently the
Android Browser app does not include any HTML5 capabilities. It does
include Gears, which might be useful to some developers but
unfortunately
has no counterpart for the <audio> tag.
- Dan

On Oct 25, 12:50 pm, Damien Elmes <reso...@ichi2.net> wrote:
> does webkit on android support html5 audio tags? if so, that would be
> very easy to implement.
>

Andrew

unread,
Oct 25, 2009, 4:20:47 PM10/25/09
to anki-a...@googlegroups.com
When Motorola accidentally linked to specs for the upcoming Verizon device, among the features is an HTML5 browser:
http://www.boygeniusreport.com/2009/10/22/motorola-droid-makes-appearance-on-motorolas-site/

I think it's supposed to be the first Android 2.0 phone, but I imagine that means it won't be long before it's an option.

Casey Link

unread,
Oct 25, 2009, 4:41:28 PM10/25/09
to anki-a...@googlegroups.com
On Sun, Oct 25, 2009 at 3:41 PM, Brian Bush <brian...@gmail.com> wrote:
>
>> > I don't think so. I thought the long term goal was to share as much Anki
>> > code as possible, but maintain an Android UI.
>
> One way to use the current java UI would be to talk to ankimini server
> with JSON, then the UI could be more consistent with the platform.
> Then ankimini would only need to be changed to send/receive JSON
> (versus HTML) and we would gain all the benefits of the anki platform.
> Just my two cents.

Yes, but how to get ankimini running in a package straight from the
market? That is the main issue.


Personally, I'm not investing more time into Anki on Android, because
of the lack of Arabic support in the WebView. I've mucked around with
generating images from the text, but haven't been able to accurately
reproduce the Arabic text in an image.

Casey

Nicolas Raoul

unread,
Oct 26, 2009, 9:09:43 AM10/26/09
to anki-a...@googlegroups.com
Hello all,

To summarize, here are the different ways to study on Android:
- Native application
- ankimini (libanki + embedded server + web UI)
- AnkiOnline ( http://anki.ichi2.net )
- iAnki (same concept as AnkiOnline, but server is on your home PC)

If you know any other way, please share your knowledge :-)

The native application's SRS and synchronization features could reuse
libanki in the future (and using JSON is a bright idea for this), but
a number of problems have to be overcome. The biggest problem was
getting all the libraries to work, many thanks to Brian for his work
on this! Another problem is to make installation straightforward for
the average cellphone user, which means a click in the Market. I
didn't look at this so I don't know much... Edu maybe you could check
and evaluate the feasibility of integrating libanki and Ankidroid in
an APK?

Months ago, when I looked at ASE, it looked like it was not intended
to be used by applications, but rather a way to write scripts to test
things on-the-fly. I had a feeling that somehow Google wants
developers to use Dalvik (Java) and was not enthusiastic about people
using Python for Android. And even now, the last paragraph of ASE's
homepage makes it look like it's not for writing applications. It
would not be too surprised if Google suddenly did something that
breaks ASE's way of working. Not to say that ASE is not great, but I
feel a bit apprehensive about totally relying on it.

Right now ASE is not yet available in the Market, it requires the user
to download and APK and install it, which might be easy for a hundred
of us, but clearly out of reach for most of our 1500+ users. I don't
see this problem resolved before a few months at least. Meanwhile, how
about an application that would use libanki if detected, and Java SRS
if not? That would mean top-notch SRS for the happy fews, and
as-good-as-we-can Java SRS for all of the other Ankidroid users?

Cheers,
Nicolas Raoul.

Casey Link

unread,
Oct 26, 2009, 9:15:16 AM10/26/09
to anki-a...@googlegroups.com
On Mon, Oct 26, 2009 at 9:09 AM, Nicolas Raoul <nicola...@gmail.com> wrote:
>
> Hello all,
>
> To summarize, here are the different ways to study on Android:
> - Native application
> - ankimini (libanki + embedded server + web UI)
> - AnkiOnline ( http://anki.ichi2.net )
> - iAnki (same concept as AnkiOnline, but server is on your home PC)
>
> If you know any other way, please share your knowledge :-)
>
> The native application's SRS and synchronization features could reuse
> libanki in the future (and using JSON is a bright idea for this), but
> a number of problems have to be overcome. The biggest problem was
> getting all the libraries to work, many thanks to Brian for his work
> on this! Another problem is to make installation straightforward for
> the average cellphone user, which means a click in the Market. I
> didn't look at this so I don't know much... Edu maybe you could check
> and evaluate the feasibility of integrating libanki and Ankidroid in
> an APK?
>
> Months ago, when I looked at ASE, it looked like it was not intended
> to be used by applications, but rather a way to write scripts to test
> things on-the-fly. I had a feeling that somehow Google wants
> developers to use Dalvik (Java) and was not enthusiastic about people
> using Python for Android.
I agree.. though when I talked to the ASE dev on IRC, he seemed
optimistic that what we wanted would be implemented in the future
(tm).

> Meanwhile, how
> about an application that would use libanki if detected, and Java SRS
> if not? That would mean top-notch SRS for the happy fews, and
> as-good-as-we-can Java SRS for all of the other Ankidroid users?

That is a good idea, and think the key would be to abstract the UI
from the underlying SRS implementation, so we don't run into any
headaches down the road. Theoretically, it would be nice to be able to
plugin a native python libanki, java SRS, or even ankimini, with the
same GUI with minimal plumbing changes.

Casey

Andrew

unread,
Oct 26, 2009, 12:36:54 PM10/26/09
to anki-a...@googlegroups.com
I want to do a bit more investigation (when I'm not at work), so maybe sometime this week, but...

I looked at the ASE source briefly and it seems to simply know where the executables it has are (eg, python, beanshell, etc). It looks like it just compiles an exec()-type method and then execs a shell, then runs the interpreter that way.

I think we could just bundle the python binary (it mentions that it puts it in res/raw, but I didn't see it there), and create a sub-process with it. While we could use http or any other proto, I don't think we need parallel processing so simply using stdin/stdout with json might be a simple start.

Here are some problems that I imagine might crop up:
- The python binary is 1.4mb :(
- Not sure how ASE makes sure the interpreter has executable permissions in the APK.
- We do still need some bridge protocol.
- We need to store the Anki source somewhere.
- Native development on Android could eventually be a problem, when devices running other platforms, like x86, etc, come out.
Reply all
Reply to author
Forward
0 new messages