android - java.lang.NoClassDefFoundError : Failed resolution of: Ljava/time/LocalTime; 错误

标签 android build.gradle android-studio-2.1

我正在使用 Android Studio 2.1.2 API 级别 23 开发应用。 在一个类中,我使用了 java.time.LocalTime 类,但在运行时,一个未处理的 NoClassDefFoundError 异常终止了我的 Activity 。谷歌搜索,我了解到我必须在 build.gradle 中添加依赖项,因为 Android 类是使用早于 Java 8 的 JDK 版本开发的(当添加了 LocalTime 类时)。

所以我必须这样写:compile "java.time:LocalTime:1.8"

但它不起作用。

最佳答案

Android 运行时支持 JDK 8 中增强的标准库的有限子集。不支持 JDK 8 日期时间库。你可以使用类似 http://www.threeten.org/threetenbp/ 的东西

关于android - java.lang.NoClassDefFoundError : Failed resolution of: Ljava/time/LocalTime; 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39214705/

相关文章:

android - Android 上与 Qt 5.2 的蓝牙通信

java - CompletableFuture API17 的替代品

android - Jacoco 与 Gradle 0.10.0 : Remote object doesn't exist

android - "No resource found that matches the given name..:"- Android Studio 2.1.2 (React Native App)

java - 为什么我的应用程序上不断收到 “Unfortunately, <App> has stopped”? (Java,Android Studio)

android - 如何在后台运行android应用程序

java - 这种声明的类型是什么?

安卓工作室 3.1.3 错误 : Unable to resolve dependency

android - java.lang.NoSuchMethodError : No virtual method setSkipClientToken(Z)V in class Lcom/facebook/GraphRequest;

java - Android Studio : Android Theme. AppCompat 错误