Android Studio 3.0 中的 java.time 在哪里? [英] Where is java.time in Android Studio 3.0?

查看:37
本文介绍了Android Studio 3.0 中的 java.time 在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Android Studio 文档:

According to Android Studio documentation:

Android Studio 3.0 引入了对 Java 8 库的内置支持

Android Studio 3.0 introduces built-in support for Java 8 libraries

但是 Java 8 的一个巨大改进是使用了新的 java.time 库.目前,这个库似乎没有包含在这个版本中.

But a huge improvement in Java 8 is the use of the new java.time library. For now, this library seems not included in this version.

所以我的问题是:我错了吗?如果没有,是否有任何解决方法可以在 Android 应用程序中使用此库?

So my question: I'm I wrong ? If not, is there any workaround possible to use this library in Android applications ?

推荐答案

要在 Android Studio 中运行 Java 8 语言功能支持,请检查以下四点:

To get Java 8 language feature support running in Android Studio, check these four things:

  1. 确保您运行的是最新版本的 Android Studio 3.0

  1. Make sure you are running the latest version of Android Studio 3.0

确保您使用的是嵌入式 JDK

Ensure you are using the embedded JDK

更新您的来源和在您的项目结构中将兼容性版本目标为 1.8.

Update your the source and target compatibility versions to 1.8 in your project structure.

确保您的 minSdkVersion 为 24(或 26/'O',具体取决于哪种方法你想在课堂上使用)

Ensure you minSdkVersion is 24 (or 26/'O' depending on which method you want to use in the class)

一旦您的项目符合这些设置,您就可以将诸如import java.time.LocalDateTime;之类的库添加到您的项目中.查看此页面了解更多信息:https://developer.android.com/studio/preview/features/java8-support.html

Once your project complies with those settings, you can add libraries such as: import java.time.LocalDateTime; to your project. Check out this page for more information: https://developer.android.com/studio/preview/features/java8-support.html

这篇关于Android Studio 3.0 中的 java.time 在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆