Home > Android, Clutter > Clutter on Android: first results

Clutter on Android: first results

With the release of Android 2.3, there’s a decent way to integrate native applications with the NativeActivity class, an EGL library, and some C API to expose events, main loop, etc. So? how about porting Clutter to it now that it looks actually feasible? After a few days of work, the first results are there, quite promising!

There’s still a fairly large number of items in my TODO before being happy with the state of this work, the most prominent items are:

  • Get a clean up pass done to have something upstreamable, this includes finishing the event integration (it receives events but not yet forward them to Clutter),
  • Come up with a plan to manage the application life cycle and handle the case when Android destroys the EGL surface that you were using (probably by having the app save a state, and properly tear down Clutter).,
  • While you probably have the droid font installed in /system/fonts, this is not part of the advertised NDK interface. The safest choice is to embed the font you want to use with your application. Unfortunately fontconfig + freetype + pango + compressed assets in your Android package don’t work really well together. Maybe solve it at the Pango level with a custom “direct” fontmap implementation that would let you register fonts from files easily?
  • What to do with text entries? show soft keyboard? Mx or Clutter problem? what happens to the GL surface in that case?
  • Better test the GMainLoop/ALooper main loop integration (esp. adding and removing file descriptors),
  • All the libraries that Clutter depends on are linked into a big .so (which is the Android NDK application). It results in a big .so (~5 MB, ~1.7 MB compressed in the .apk). That size can be dramatically reduced, sometimes at the expense of changes that will break the current API/ABI, but hell, you’ll be statically linking anyway,
  • Provide “prebuilt libraries”, ie. pre-compiled libraries that makes it easy to just use Clutter to build applications.
Categories: Android, Clutter
  1. marwee
    July 27th, 2011 at 18:14 | #1


    Your clutter port looks very nice. But i didn’t found the source in the git-repositories. Would you release it?


  2. July 28th, 2011 at 23:39 | #2

    Hey, I haven’t touched the port since that post. However I have a talk at the Desktop Summit in a week and I do intend to have a “preview” release for people to play with. Stay tuned!

  3. August 4th, 2011 at 13:53 | #3

    Do you think clutter has to use the NDK, or would it be possible to port the whole lot over to Java and use Dalvik?

  4. August 5th, 2011 at 09:08 | #4

    @Patrick: For now, it’s NDK only. It’s possible to make it work from the Java side, it’s quite a lot of work though.

  5. Vishal
    December 15th, 2011 at 06:29 | #5


    I have downloaded your code , and tried that to create .so file using ndk-build command but it is failed to build.
    As it is not finding clutter modules in NDK , how i need to provide clutter modules to it.

  6. sduclos
    December 20th, 2011 at 14:58 | #6

    do this:

    export NDK_MODULE_PATH=/clutter-android-prebuilts

    you can test with:

    $ cd /cogl-1.9.2/example/android/hello
    $ /ndk-build

  7. sduclos
    December 20th, 2011 at 15:02 | #7

    sduclos :
    do this:
    export NDK_MODULE_PATH=/clutter-android-prebuilts
    you can test with:
    $ cd /cogl-1.9.2/example/android/hello
    $ /ndk-build

    do this:

    export NDK_MODULE_PATH=\/clutter-android-prebuilts

    you can test with:

    $ cd \/cogl-1.9.2/example/android/hello
    $ \/ndk-build

  8. sduclos
    December 20th, 2011 at 15:09 | #8

    my previous post is missing “your_path_to” in the 3 path above to convey that you need the full path

  9. Vishal
    January 5th, 2012 at 06:07 | #9


    Hi sduclos ,

    I have tried your above way but still the code is jni is not compiling i am getting some errors and it is not compiling..

  10. Evandro Rathke
    February 8th, 2012 at 05:36 | #10

    Can you make available for download?

  11. sduclos
    February 9th, 2012 at 11:31 | #11

    Sorry to be late,

    clutter-android-prebuilts is already compiled

    To compile ‘hello’ in cogl source tree ‘cd’ to it and run ‘ndk-build’

    You need to set NDK_MODULE_PATH to the path of clutter-android-prebuilts before
    running the build.

    You should get a .so in libs/

  12. April 29th, 2012 at 00:33 | #12

    Hi Damien,
    Great work! I would like to test it and eventually contribute with some lines. Could you make it available for download?

    Thanks a lot!

  13. May 1st, 2012 at 02:47 | #13

    Well I find the ohand sample from your git repo. Now, as @Vishal pointed it’s complaining about missing NDK_MODULE_PATH. So, how did I get my own clutter-android-prebuilt? How can I compile clutter so I can provide ndk-build with the missing module? @diega

  14. May 1st, 2012 at 03:54 | #14

    finally got it working :) sorry for the comments flood (u can remove the old ones if u want).
    The funny thing is that it loads the app nice in my ICS Tablet but it doesn’t animate :) I just see the Hand static in the middle.

  15. May 4th, 2012 at 07:51 | #15

    @diega w00t! you’re probably the second person in the world to have that working :) Having the hand static is the intended behaviour for http://git.lespiau.name/cgit/ohand. Be aware that the prebuilt binaries provided were ultra alpha quality, using OpenGL ES1. It will fall appart if you try to use it.

    A good way to carry on this project today would be to:
    1/ build cogl with https://github.com/rib/cogl-android-sdk (the cogl part of my work here has been upstreamed and then made to work again by Robert Bragg)
    2/ port the clutter patches to 1.10 https://github.com/dlespiau/clutter/commits/android
    3/ debug the result

  16. Ivan
    June 18th, 2012 at 22:30 | #16

    Hi Damien.

    First off, thanks a lot for this post – without it, I’d be much more hesitant to start what I’m starting now with Clutter on Android.

    I’d like to build Clutter myself, using a standalone toolchain. I’m going to build each of its dependencies one by one for different API levels, ABIs and with/without NEON. Did you go through a similar process to get your results? Any blockers/traps I should prepare to?

    Also, what do you know about building/running Clutter on iOS?

  17. guofeng.routon
    June 20th, 2012 at 06:49 | #17

    Hello,I want to know how to make “Maybe solve it at the Pango level with a custom “direct” fontmap implementation that would let you register fonts from files easily” work.I have try to start this work ,but it is slowly Can you give me some suggestions?Thank you very much!!!

  1. No trackbacks yet.