OptaPlanner logo
  • Download
  • Learn
    • Documentation
    • Videos
    • Slides
    • Training

    • Use cases
    • Compatibility
    • Testimonials and case studies
  • Get help
  • Blog
  • Source
  • Team
  • Services
  • KIE
    • Drools
    • OptaPlanner
    • jBPM
    • Kogito
  • 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

Giscus Comments

AtomNews feed
Don’t want to miss a single blog post?
Follow us on
  • T
  • L
  • F
Blog archive
Latest release
  • 8.14.0.Final released
    Wed 8 December 2021
Upcoming events
  • DevConf.CZ
    Brno, Czech Republic (virtual) - Fri 28 January 2022
    • Artificial Intelligence on Quarkus: I love it when an OptaPlan comes together by Geoffrey De Smet
  • JFokus
    Stockholm, Sweden - Mon 7 February 2022
    • AI maintenance scheduling with OptaPlanner on Quarkus by Geoffrey De Smet
  • Add event / Archive
Latest blog posts
  • OptaPlanner documentation turns over a new leaf
    Tue 26 October 2021
    Radovan Synek
  • Order picking optimization in warehouses and supermarkets with OptaPlanner
    Thu 14 October 2021
    Walter Medvedeo
  • Monitor OptaPlanner solvers through Micrometer
    Tue 12 October 2021
    Christopher Chianelli
  • A new AI constraint solver for Python: OptaPy
    Tue 5 October 2021
    Christopher Chianelli
  • How much faster is Java 17?
    Wed 15 September 2021
    Geoffrey De Smet
  • Constraint Streams get some more love
    Thu 19 August 2021
    Lukáš Petrovický
  • Let’s OptaPlan your jBPM tasks (part 2) - BPM Task assigning in the cloud
    Mon 26 July 2021
    Walter Medvedeo
  • Blog archive
Latest videos
  • AI lesson scheduling on Quarkus with OptaPlanner
    Thu 18 November 2021
    Geoffrey De Smet
  • Maintenance scheduling
    Fri 12 November 2021
    Geoffrey De Smet
  • Optimized order picking in warehouses and supermarkets
    Tue 26 October 2021
    Walter Medvedeo
  • A modern OO/FP constraint solver
    Tue 14 September 2021
    Geoffrey De Smet
  • Business processes task optimization in Kogito
    Tue 7 September 2021
    Walter Medvedeo
  • School timetable optimization
    Mon 6 September 2021
    Geoffrey De Smet
  • Schedule incoming calls real-time
    Mon 23 August 2021
    Radovan Synek
  • 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

KIE projects

  • Drools rule engine
  • OptaPlanner constraint solver
  • jBPM workflow engine
  • Kogito Business Automation platform
CC by 3.0 | Privacy Policy
Sponsored by Red Hat