Skip to Navigation | Skip to Content



A Tale of Two Androids | March 18th, 2010

After being shown many more ways of writing applications on Android, I decided to investigate the possibility of using the V8 Javascript Engine in Android Scripting Environment. I saw what was done with the other platforms, so it should just be a simple matter of porting node. Unfortunately, I’m not there yet, so I started with what I know should exist, which is V8.

Blogs have it on good authority that Android Webkit now uses V8 as its Javascript Engine instead of JSC as it used to in previous versions of Android. Now, in the Android Open Source Project, the build system that is used there (which has even less documentation than the WebKit docs on the Android SDK), has the ability to compile every single module in Android independently. However, if you type the following:


make modules

You will notice that libv8 and v8shell are lacking. However, if you run this:


make modules JS_ENGINE="v8"

You will then notice that you will have access to these things. Given that most phone companies do their own builds of the OS, it’s not clear which phone has v8 and which phone does NOT have V8. I’m certain HTC knows this, but what about Motorola, Sony, LG, Dell, Acer or any of the other manufacturers of phone who all do their own builds and all have their own buildbots. It’d be great if you could find out which engine you were running on your phone, since WebKit can run many JavaScript engines, and soon we’ll be able to run Javascript on the phone wherever we want. Of course this is more pie in the sky than the reality, which looks like this:

adb shell
$ cd /tmp/
$ ./v8shell
V8 version 1.3.10 (candidate)
> print('Hello world');
Hello world
>

We’re working on it, and we’ll see what happens when this does exist. In the meantime, the DroidScript stuff is really interesting, and the more ways to develop on Android, the better. While some people are married to the idea of Java, I like the idea of writing whatever works for the developer. If anyone can recommend some solid books on Makefiles, that would be greatly appreciated. If I ever manage to get this to work, I’ll have an APK for download.

Posted in Android, phonegap | 8 Comments » | Add to Delicious | Digg It

This entry was posted on Thursday, March 18th, 2010 at 6:28 pm and is filed under Android, phonegap. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

8 Responses to “A Tale of Two Androids”

  1. Dennis Says:

    Is the V8 that faster than the JSC? Shouldn’t android 2.0 be v8 only?

  2. Joe B Says:

    I haven’t run the benchmarks, so I don’t know. In fact, I have no idea what’s running on my droid right now because AFAIK, there’s no way to tell which Javascript Engine is running. I do know that on the Android Open Source Project, for me to create an Android build with V8, I had to use the flag. Since the AOSP is the basis for vendors to start with when developing for their platform, it’s possible that a lazy build engineer to not turn on v8 and use JSE.

    All of a sudden, getting the type of Javascript Engine is important, at least when it comes to measuring performance.

  3. N.V.Balaji Says:

    You can try placing all your native access inside an NP scriptable plug-in. This way you can be agnostic to the JS engine. Phonegap can provide a JS that would add an invisible object to load the plug-in (Like the way Google Gears does. initgears.js). By the way Android supports loadable Plug-ins from Eclair version

  4. Kelly Says:

    I’ve been combing the web and testing solutions for a week trying to access V8 directly to no avail.

    I tried the ‘make modules JS_ENGINE=”v8″‘ but I get garbage and an error, so I just did ‘make JS_ENGINE=”v8″‘ and I got a lot of errors at the end for undefined references back to JSC. Do you have any other unique setting in your platform?

  5. Jeff Says:

    tell me please, which is good Android phone? HTC or Samsung, i saw this post good enough compare that…..

    Joe, which handset your own?

  6. Joe B Says:

    N.V.Balaji: Plugins are deprecated currently after Google Gears was removed in Android 1.6. Also, the documentation for Plugins is almost completely non-existent.

    Kelly: All I can suggest is that you update your source. I build on Ubuntu 9.10 and it seems to work without problems. However, you do need to specify which module you are building, namely v8shell.

    Jeff: I currently own a Motorola Milestone. I personally dislike Samsung phones due to their limited availability, and the fact that many of them are stuck on Android 1.5. I would recommend the Nexus One or the Motorola Milestone/Droid for Android development. The Sony Ericsson Xperia X10 is not a bad choice either.

  7. N.V.Balaji Says:

    Joe B: Android 2.0 still seems to support loadable plug-ins. APKs with PLUGIN_ACTION is searched when the browser encounters an tag. You may want to check getPluginDirectories() in pluginmanager.java

    We managed to run the example plug-ins and learn how to write scriptable plug-ins.

    You may check the examples at: development/examples

    You may already know the following links (we found them useful for plug-ins):

    1. https://developer.mozilla.org/en/Gecko_Plugin_API_Reference:Plug-in_Basics#Windowed%20and%20Windowless%20Plug-ins

    2. http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/intro.html#1001793

  8. Jason Says:

    Anyone ever make an APK for this?

Leave a Reply