Toggle navigation OptaPlanner logo
  • Home
  • Download
  • Learn
    • Documentation
    • Videos
    • Slides
    • Training
    • Use cases
    • Compatibility
    • Testimonials and case studies
  • Get help
  • Source
  • Team
  • Services
  • Star
  • @OptaPlanner
  • Fb
Fork me on GitHub
  • 3 Bugs in The Ultimate American Road Trip of Th...
  • How good are human planners?

OptaPlanner on Android

Tue 19 May 2015

Avatar Tomáš David

Tomáš David


GitHub

Contributor

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.

Try the app on the Google Play app store.

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 package.

  • 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) {
        additionalParameters=['--core-library']
    }
    ...
}
  • 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:

Get this app from the Google Play app store now. The source code is on GitHub.

Conclusion

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


Comments Permalink
 tagged as android vehicle routing

Comments

Visit our forum to comment
  • 3 Bugs in The Ultimate American Road Trip of Th...
  • How good are human planners?
Atom News feed
Don't want to miss a single blog post?
Follow us on
  • T
  • Fb
Blog archive
Latest release
  • 8.5.0.Final released
    Thu 15 April 2021
Upcoming events
  • SouJava MOTU
    Worldwide - Thu 15 April 2021
    • Planejamento de Recursos com OptaPlanner by Karina Varela, Otávio Santana
Add event / Archive
Latest blog posts
  • Batch solving an ActiveMQ queue that contains planning problem data sets in a scalable way
    Thu 25 March 2021
     Radovan Synek
  • Optimizing COVID-19 vaccination appointment scheduling
    Thu 4 March 2021
     Paul Brown
  • How much faster is Java 15?
    Tue 26 January 2021
     Michal Tomčo
  • Solve the facility location problem
    Fri 9 October 2020
     Jiří Locker
  • OptaPlanner Week 2020 recordings
    Mon 7 September 2020
     Geoffrey De Smet
  • Let’s OptaPlan your jBPM tasks (part 1) - Integrating the two worlds
    Fri 3 July 2020
     Walter Medvedeo
  • AI versus Covid-19: How Java helps nurses and doctors in this fight
    Fri 8 May 2020
     Christopher Chianelli
Blog archive
Latest videos
  • YT Unit testing constraints
    Tue 9 March 2021
     Lukáš Petrovický
  • YT Maintenance scheduling
    Wed 24 February 2021
     Julian Cui
  • YT Vaccination appointment scheduling
    Wed 3 February 2021
     Geoffrey De Smet
  • YT Shadow variables
    Tue 19 January 2021
     Geoffrey De Smet
  • YT Domain modeling and design patterns
    Tue 17 November 2020
     Geoffrey De Smet
  • YT Quarkus insights: AI constraint solving
    Tue 20 October 2020
     Geoffrey De Smet
  • YT AI in kotlin
    Wed 23 September 2020
     Geoffrey De Smet
Video archive

KIE projects

  • Drools rule engine
  • OptaPlanner constraint solver
  • jBPM workflow engine

Community

  • Blog
  • Get Help
  • Team
  • Governance
  • Academic research

Code

  • Build from source
  • Submit a bug
  • License (Apache-2.0)
  • Release notes
  • Upgrade recipes
Sponsored by
Red Hat
More coder content at
Red Hat Developers
© Copyright 2006-2021, Red Hat, Inc. or third-party contributors - Privacy statement - Terms of use - Website info