WorkManager: java.lang.NoClassDefFoundError: java.time.Duration on api 23
Environment
- CLI: 6.8.0
- Cross-platform modules: 6.5.12
- Android Runtime: 6.5.3
- iOS Runtime (if applicable):
- Plugin(s): Fresh angular helloworld project created with the CLI.
Describe the bug Runtime error when instantiating 'androidx.work.PeriodicWorkRequest.Builder' on api 23:
new androidx.work.PeriodicWorkRequest.Builder(
com.tns.workers.MyWorker.class,
15,
java.util.concurrent.TimeUnit.HOURS
).build()
Error: java.lang.NoClassDefFoundError: java.time.Duration
To Reproduce
Clone sample project and tns run android on an api 23 device.
Expected behavior No error. On api >=27 seems to work as expected.
Sample project https://github.com/JosepBergay/ns_workermanager_test/
Additional context Also mentioned here: https://github.com/NativeScript/android-runtime/issues/1488#issuecomment-616574659
As stated here: https://developer.android.com/reference/java/time/Duration this API is added in Android API 26
As stated here: https://developer.android.com/reference/java/time/Duration this API is added in Android API 26
Thanks, didn't know that. But I'm not (at least directly) using Duration API and neither does the constructor. OneTimeWorkRequest seems to work as expected, even when applying an initial delay with a method that has an overload involving Duration too.
If WorkManager is supposed to work on >14, how can I then build a PeriodicWorkRequest from NativeScript?