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 =).
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 ;).
- 리믹스하고 매시업이 만드는 사람 좋아해요: DJs From Mars / Favorite Remixer and Mashupers: DJs From Mars
- 티비-드라마: 혼 / TV-Series: Soul