OptaPlanner logo
  • Download
  • Learn
    • Documentation
    • Videos

    • Use cases
    • Compatibility
    • Testimonials and case studies
  • Get help
  • Blog
  • Source
  • Team
  • Services
  • Star
  • T
  • L
  • F
  • YT
Fork me on GitHub

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

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.


Permalink
 tagged as android vehicle routing

Comments

Visit our forum to comment
AtomNews feed
Don’t want to miss a single blog post?
Follow us on
  • T
  • L
  • F
Blog archive
Latest release
  • 8.35.0.Final released
    Fri 3 March 2023
Upcoming events
    Add event / Archive
Latest blog posts
  • OptaPlanner 9 is coming
    Tue 21 February 2023
    Lukáš Petrovický
  • Farewell - a new lead
    Tue 15 November 2022
    Geoffrey De Smet
  • Run OptaPlanner workloads on OpenShift, part II
    Wed 9 November 2022
    Radovan Synek
  • Bavet - A faster score engine for OptaPlanner
    Tue 6 September 2022
    Geoffrey De Smet
  • Run OptaPlanner workloads on OpenShift, part I.
    Thu 9 June 2022
    Radovan Synek
  • OptaPlanner deprecates score DRL
    Thu 26 May 2022
    Lukáš Petrovický
  • Real-time planning meets SolverManager
    Mon 7 March 2022
    Radovan Synek
  • Blog archive
Latest videos
  • The Vehicle Routing Problem
    Fri 23 September 2022
    Geoffrey De Smet
  • Introduction to OptaPlanner AI constraint solver
    Thu 25 August 2022
    Anna Dupliak
  • On schedule: Artificial Intelligence plans that meet expectations
    Sat 23 July 2022
    Geoffrey De Smet
  • Host your OptaPlanner app on OpenShift (Kubernetes)
    Mon 7 February 2022
    Geoffrey De Smet
  • OptaPlanner - A fast, easy-to-use, open source AI constraint solver for software developers
    Mon 31 January 2022
  • Order picking planning with OptaPlanner
    Fri 31 December 2021
    Anna Dupliak
  • AI lesson scheduling on Quarkus with OptaPlanner
    Thu 18 November 2021
    Geoffrey De Smet
  • Video archive

OptaPlanner is open. All dependencies of this project are available under the Apache Software License 2.0 or a compatible license. OptaPlanner is trademarked.

This website was built with JBake and is open source.

Community

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

Code

  • Build from source
  • Issue tracker
  • Release notes
  • Upgrade recipes
  • Logo and branding
CC by 3.0 | Privacy Policy
Sponsored by Red Hat