OptaPlanner on Android

Developing of mobile applications on Android is currently very popular.
One of the reasons for this popularity is Java programming language.
Although OptaPlanner is written completely in pure Java (Standard Edition),
the current version (6.2.0.Final) requires a workaround to work on Android due to a limitation in the Android platform.
In this article, I will show how to use OptaPlanner on Android and demonstrate a simple Vehicle Routing app.

How to use OptaPlanner on Android

Update: as of OptaPlanner 6.3.0.Beta2, this workaround is no longer needed, because OptaPlanner does not import the java.beans package any more.

Android is not a complete JVM. Some JDK libraries of the java.beans package are missing for OptaPlanner 6.2 to work out of the box.
However, it is possible to use OptaPlanner with Java score calculation by adding those missing libraries to your
Android project. The Drools rule engine does not work on Android yet, so Drools score calculation doesn’t work on Android.

If you would like to use OptaPlanner in your Android project, follow these steps:

  • Download OpenBeans redistribution of the java.beans

  • Download Jar Jar Links utility for repacking the redistribution.

  • Create a jarJarRule.txt text file with a single line:

rule com.googlecode.openbeans.** java.beans.@1
  • Place all the files in the same folder and run the command:

$ java -jar jarjar-1.4.jar process jarJarRule.txt openbeans-1.0.jar javabeans-1.0.jar
  • Move the created javabeans-1.0.jar into the libs folder in your Android project.

  • Add these lines to android area in the build.gradle file in your Android project to allow classes of the java.* package
    inside the javabeans-1.0.jar file to be used:

android {
    dexOptions {
        preDexLibraries = false
    project.tasks.withType(com.android.build.gradle.tasks.Dex) {
  • Add a dependency to the build.gradle file in your Android project and exclude org.drools and xmlpull dependencies:

dependencies {
    compile('org.optaplanner:optaplanner-core:...') {
        exclude group: 'xmlpull'
        exclude group: 'org.drools'

Vehicle Routing Problem application

I created an OptaPlanner Android application named Vehicle Routing Problem. It is based on Vehicle routing
application from OptaPlanner Examples. See this video for a detailed demonstration:


Now you can create your own Android applications which use OptaPlanner. Follow the steps written above or get inspired
by the mentioned example.


This post was original published on here.
0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments