Back

How to get Ankimini working on Android (1.5, CUPCAKE)

#1
Ok, here is my writeup from the USENET ankidroid list. I have ankimini 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/s...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/sqlal...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)
Reply
#2
bump this one up. I have an htc magic running SPL 1.76.0003, radio 6.29.... and cursorsense (cupcake) and i'm really keen to get this working.


I'm currently trying to set this up but i'm having some issues. Initially the install of the python interpreter just wasn't working (installation failed every time) so i had to use adb shell and manually extract the zip files into the appropriate locations (what i think are the appropriate locations). anyway, i've gotten past that now scripts will actually start to run and i'm down to step 12 where i'm getting the following error:

ImportError: No module name cgi

this is being caused when modules are loaded with the following line on line 12 of my main.py:

import time, cgi, sys, os, re, subprocess, threading, traceback

If i move cgi to the end of the queue or call it on a separate line it just has problem with os (but it can apparently find time and sys no problems). the modules (cgi, os, etc) are all sitting in /data/data/com.google.ase/python/*.*

any ideas? I'm thinking it's to do with the install of the python interpreter (i think) but tbh i have nfi about all this ase or python stuff so i'm not really sure. I can drive adb ok and have an average grasp of linux so if anyone who knows a bit more wants to throw their hat into the ring it would be much appreciated...
Reply
#3
In addition to this, i'm getting the following error when i try to just open the interpreter:

'import site' failed; use -v for traceback

from what i can tell it's an ase installation error :|
Reply
MONSTER Sale Get 28% OFF Basic, Premium & Premium PLUS! (Oct 16 - 27)
JapanesePod101
#4
This should probably be on the anki forum.
Reply
#5
Using brianobush's instructions it has been working for me for a few weeks. But note I can only use it when connected to the net. The browser will not let me go to 127.0.0.1 or localhost unless I am connected. But beyond that the instructions worked first time on a htc hero.
Reply
#6
chamois Wrote:In addition to this, i'm getting the following error when i try to just open the interpreter:

'import site' failed; use -v for traceback

from what i can tell it's an ase installation error :|
make sure that you using the correct ASE version. The latest versions of ASE only support Android 2.0.
Reply
#7
jamiemw Wrote:Using brianobush's instructions it has been working for me for a few weeks. But note I can only use it when connected to the net. The browser will not let me go to 127.0.0.1 or localhost unless I am connected. But beyond that the instructions worked first time on a htc hero.
I found this out while in Japan recently and thought it was a horrible design flaw in android. Could only study at home, which limited its usefulness. Those four hour train trips would have been excellent way to clear reviews that had piled up.
Reply
#8
apologies, i fail at google.

I just followed the instructions for manually installing interpreters that i found here instead: http://code.google.com/p/android-scripti...terpreters

I had the structure all wrong - i had everything sitting in data/data/com.google.ase/... but i really needed all of my extras on the sdcard.

so yeah, i've pushed past my initial problem and now it's launching python interpreter and running into script errors in main.py but i suspect they are caused by a similar problem. I'm going to clear everything i've done and start from scratch. will post back once i get it working.

thanks for the suggestions, guys

ps/ surely there's a way to get around the necessity to have a net connection to access localhost.... no one has found one?
Reply
#9
win! structure of files in sdcard/ase/ was critical, perhaps there have been changes since the newer versions of ase and anki have come out such that brian's guide doesn't work, or perhaps there are funny things going on with paths that i can't figure out. for the record i got it working by doing the following:

install ase
unzip python_v2.zip -> data/data/com.google.ase/ <-you need root+busybox for this
unzip python_extras_v2.zip -> sdcard/ase/extras/
python_scripts_v2.zip -> sdcard/ase/scripts/
simplejson-2.0.9/ -> sdcard/ase/scripts/
SQLAlchemy-0.5.6/ -> sdcard/ase/scripts/
anki+ankiqt -> sdcard/ase/scripts/
ankimini/main.py -> sdcard/ase/scripts/
ankimini-config.py -> sdcard/anki/
move a random deck -> sdcard/anki/ <- didn't work with a virgin deck
mod main.py as described
mod ankimini-config.py as described

make a shortcut to main.py on my phone's desktop, run, open 127.0.0.1:8000 and it's golden.

thanks for your help guys.


EDIT: the "not working in aircraft mode" doesn't seem to be happening for me - i've just tried a few times and it seems to just keep on keeping on. can you guys describe the issue and a means for me to reproduce it so i can try to figure it out? I'm trying to get my new SRS set up for a 6 week holiday when i'll be almost permanently incommunicado... thanks Big Grin
Edited: 2010-01-20, 1:19 am
Reply
#10
Hi Chamois,

When in aircraft mode and I try to start the browser I immediately get the following message:

"This application requires network access. Enable mobile network or Wi-Fi to download data."

I tried another browser, with the same result. It is not only when starting the browser either, when I am on a train and lose connectivity it won't let me go to the next card without the browser giving the same message.

Beyond that problem I have found it really usable.

Thanks,
Jamie
Reply
#11
weird, I'm not seeing the issue at all. I'm running a hero rom though which uses a different browser. a little drastic, but perhaps you could try rooting and flashing a hero rom to see if the issue is solved by the new browser?

I am having issues with downloading decks though - i'm getting "Download failed! unicode() argument 2 must be string, not None" when i try to download an online deck. did you guys have to do anything special to get your decks to sync?

thanks Big Grin
Reply
#12
Well I mainly bought the phone for reviewing on the move so I may take that drastic action if I don't come up with anything else! It is really annoying though because outside of that it works really well...

I had a few errors when I first started syncing, I can't remember exactly what they were, however, the following got rid of them.

1. I downloaded my decks from the anki server on to a pc.
2. I deleted my online decks and the decks on the phone.
3. I copied the decks from the pc to the phone manually.
4. I recreated the decks online.
5. Rebooted phone.

So then all 3 places (pc, phone, online) definitely had decks that matched exactly.

Since then I have not had any problems syncing (and one deck is quite big (25000 cards)).
Reply
#13
chamois Wrote:ps/ surely there's a way to get around the necessity to have a net connection to access localhost.... no one has found one?
not a fix but you could try ankitty instead
Reply
#14
thanks jamie, but got my sync working via other means - main.py was trying to use a python command which doesn't seem to work on android/ase (sys.getfilesystemencoding()) so i removed it and manually entered the value "utf-8" and it seems to be working ok. I also have to manually delete or rename the old version of the deck before downloading or it won't let me overwrite. could probably fix that too if i can find the time...

rooting and romming is pretty easy once you get into it. first time is pretty scary though. I'll do some more extensive testing over the next few days but i haven't seen any signs of errors with no network...

cangy: that's awesome, will definitely script that for emergency use. thanks Smile
Reply
#15
I am almost finished with my Bachelors in Computer Science and I still have no idea how to perform all these steps Wink ! I think Im not the only one- perhaps I could suggest someone rewrites this in a more easy to understand and user friendly way?

Simply unpacking (tar -zxvf) and then moving the files into the android SD card will mean that all these things are installed? No further actions on the phone itself is required?

What exactly do you mean by

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

What files is it that we are supposed to download?

Further: Its really important for me that, in a large deck such as the RTK deck with around 3000 cards in it, I can specify what cards to practice, rather than all of them. Is this possible with this solution? Its not possible with the android app from market.
Reply
#16
kinesiskatecken Wrote:5. Download and install Anki (libanki), basically copy libanki/anki to
/media/disk/ase/scripts/
cp -r libanki/anki/ /media/disk/ase/sc
libanki is part of anki. Download the source for anki and it will be there. You almost have a CS degree? Well, play, hack. Look at things. Open files. Break shit. That is how you learn how things work. The worse you can do is mess up the installation and anki can't start.

I have a large deck (~1500 sentences) that I use daily on my phone. Actually, I never use the PC app nowadays.
Reply
#17
i'm japan at the moment with horribly expensive roaming charges so i've had data switched off and i've managed to re-create the "this application requires network access" fault intermittently. weird, cos i did like 500+ reps on the plane coming over in aircraft mode with no issues and now i'm having the problem every now and then.

what i did do that was different was download the deck manually (ie, archived the old one and then USB'd from my netbook onto my phone) and then the problems started. since then i've re-sync'd via the 3g network and it has started working again without fault. as i said, weird. why would downloading a deck make it somehow different to just transferring it via usb? idk but that may be part of the problem. there still remains the issue of some android web browsers not letting you use them without a net connection though - does android contain any other application that could be used to render the pages in something other than html?
Reply
#18
ok, so i've been thinking on this on my holidays and i thinking in a few different directions:

1) ankimini works no problems as soon as i boot. if i use taskiller to kill applications it won't work again until i reboot the phone. i think that booting sets things up in a particular way and then the unexpected killing and restarting of things changes a critical setting which prevents it from working anymore. Could someone else having this problem try launching ankimini straight after booting without taskilling in anyway to see if it works for them?

2) i read a few things about setting up local loop VPN. perhaps someone with a bit more knowhow than me could figure out a way to make an android device VPN with itself which may trick the webkit into letting you browse anything you want without an external connection

3) i've been digging around also looking for configuration files that are different between when ankimini works and when it doesn't but i need a way to pull the entire system and data partitions - is there an adb command for this?

4) there is an internal htmlviewer however i can't get the bloody thing to launch :| you can use content://com.android.htmlfileprovider/sdcard/example/file.html to load local html content but it doesn't work for the localhost....

ideas, discussions?

thanks
Reply