java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/LocalTime;
Asked Answered
S

2

7

I'm developing an app using Android Studio 2.1.2, API level 23. In a class I used the java.time.LocalTime class, but at runtime an unhanded NoClassDefFoundError exception kills my activity. Googling, I understood that I have to add dependencies in build.gradle because Android classes are developed using a version of JDK older than Java 8 (when the LocalTime class has been added).

So I have to write something like: compile "java.time:LocalTime:1.8"

But it doesn't work.

Southeast answered 29/8, 2016 at 20:31 Comment(0)
P
6

The Android runtime supports a limited subset of the standard library enhancements made in JDK 8. The JDK 8 date time library is not supported. You can use something like http://www.threeten.org/threetenbp/

Predominate answered 31/8, 2016 at 16:26 Comment(0)
P
1

Upgrade your API version on Emulator or Device. It works upper 26 version (starts from Oreo).

Peavey answered 13/2, 2018 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.