Monday, October 26, 2009

Getting Ankimini working on Android

I recently got a new phone, an android-based Motorola Cliq. Pretty nice phone and my first foray into android. I have lately been adding more Japanese sentences with heavier vocabulary terms and need to study them more frequently as opposed to cramming them in late at night. Thus, I need anki working on my mobile device.

So, after several hours of hacking with ankimini - It is working, but not completely. Currently there is no sound capability - since there is no command line mp3 playing capability in android. I will keep this post up to date with any fixes I find.

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/ … 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/sqla … z?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)