Search code examples
timefold

How can I run Timefold on Android?


How can I run Timefold on Android? Specifically,

  • Does it work at all?
  • What is the minimum version of Android needed?
  • Are there gotchas?
  • Is there a minimum version of Timefold needed?
  • What is performance like?

Solution

  • Yes it works! I have successfully run Timefold 1.9.0 on Android and wanted to share my experience for anyone else who wants to do this.

    What is the minimum version of Android needed?

    • It requires API 34+ (Android 14+), because that's the version of Android that added support for Java 17, which Timefold requires.

    Are there any gotchas?

    • I wasn't able to easily get JAXB working on Android, so I couldn't load solver config XML files. I had to create my SolverConfig with the Java API. It may be that with more work loading solver config files could be made to work.

    Is there a minimum version of Timefold needed?

    • In my particular case, the default ClassLoader that was picked up by ServiceLoader inside Timefold was not able to load classes. I'm pretty sure this issue is specific to the particular circumstances of my application, which is a plugin for another system that appears to have changed something that affects this. So I had to explicitly pass in a DexClassLoader via SolverConfig::withClassLoader, which worked fine. I also needed Timefold 1.9.0 because this removed the use of ServiceLoader for Joiners, which couldn't be configured to use a specific ClassLoader.
    • Other than this, which presumably does not affect most people, earlier versions of Timefold would probably work on Android fine. In fact, I was able to work around these issues to make things work on earlier versions, but it was a total hack and I don't recommend it.

    What is performance like?

    • I don't have specific benchmarks, but for my problems (which tend to be very small) it is plenty fast on Android.