Running Akka 2.0 On Android (WIP)

This information here is allready quite outdated. With the current Akka 2.0 master snapshot some issues are gone, while new pitfalls introduced. I will update / create a new post when Akka 2.0 is close to the final release.

Akka 2.0 is available as a preview version. Here’s a short guide how to get it to run on Android. This pretty much work in progress. Maybe someone else has even has a better strategy. Let me know if that’s the case=). Also I didn’t do much with Akka 2.0 on Android yet, so maybe there are major issues yet to discover =).

Let's master this Akka beast, little Android =)

Let's master this Akka-beast, little Android =)

In general I just assume that you have a working Scala build and know how to include new Scala libraries. And I also assume that you are using Proguard to shrink the jar file. I use a build based on this. In case you are having trouble, just ask for help =).

First add the Akka 2.0 M3 jar-file to the project (The M2 bits won’t work). Make sure that it is in your directories of libraries which are compacted by Proguard. Unfortunately you will get tons of warnings by Proguard about classes which couldn’t be found, because they are not part of the Android platform. These are three categories of classes which are not available:

  • ‘ akka.util.JMX’: There is no JMX on Android.
  • ‘sun.misc.Unsafe’: Well at first sight Android doesn’t have this implementation-detail class. Luckily it actually does have it (at least in newer versions), but it’s only available at runtime. The jars which you compile against do not have this class.
  • ‘org.omg.CORBA’-stuff. The Akka library has a UUID implementation which implements some interfaces from CORBA.

So it is time for some Proguard trickery to get rid of warnings.

Bye Bye JMX

Well there is definitely no JMX on Android. So I just excluded the JMX stuff from Akka:

Ignoring ‘sun.misc.Unsafe’ Warnings

The next step is to configure Proguard to ignore the ‘sun.misc.Unsafe’ warnings. It is there on the device (If not, please tell me).

Fixing the CORBA Stuff

Well, just exclude the ‘com.eaio.uuid’ stuff and you should be fine. At least is looks like it when you are only using the basic functionality. (In Akka 1.2 the UUID class is central, in Akka 2.0 it has been replaced with the path system.):

Remove the FSM Forward Reference

The core Akka library contains a forward reference to its finite state machine (FSM) implementation. In a usual class loader environment this doesn’t matter, since classes are lazily loaded. However Proguard is going to bitch about it. So in case you are not using the FSM library remove that reference with Proguard:

Keep Important Classes

Also we need to keep some classes which are loaded at runtime. Maybe there are more required for some features, just watch for class loader errors. These are the ones you need for sure:

Work Around the Reference Configuration Issue?

I’m not sure what exactly the issue is here and probably I’m doing something wrong. At least with my setup Akka cannot find its internal reference.conf resource file. Looks like resources are only loaded from the *.apk file? Anyway, for now I just copied the reference.conf file from the Akka source code to my project (Or do it with a build task). Then everything runs.


Yes, it is a little hairy to get Akka 2.0 to run on Android. I certainly will work a little more on it. And in case it gets too bad I’ll do a shallow fork of Akka ;).

Tagged on: , , ,

5 thoughts on “Running Akka 2.0 On Android (WIP)

  1. Roland Kuhn

    Could you give more information on the FSM warning? I’d like to fix it if possible/reasonable: a casual look at our classes with grep did not give me a hint of what’s to blame.

  2. Viktor Klang


    The CORBA stuff is not present in Akka 2.0-M3, the FSM is not a forward reference since FSM is a part of akka-actor.jar, Akka 2.0-M4 won’t have akk-util.JMX anymore.


  3. Pingback: This week in #Scala (03/02/2012) | Cake Solutions Team Blog

  4. Paweł P

    I’ve tried to replicate your results, but the application doesn’t start. I have problem with sun.misc.Unsafe.
    App dies on sun.misc.Unsafe#throwException() method. Any advice?

  5. gamlerhart Post author

    Hmm, with the latest Akka 2.0 or the 2.0.1 release. Unfortunatly I haven’t tried to run that versions yet. So probably it means that Android Unsafe doesn’t implement that method. I would need to take a look.

    I’ll try to take a look when I’ve got time this week.