即使在添加对Java 8支持的废止之后,Android Studio Lint为什么仍在Date函数上报告“在较旧版本上调用新方法”?

问题描述

我安装了最新的AS 4.01,并为最新的Java 8依赖项设置了coreLibraryDesugaring(1.0.10),并在build.gradle文件中使用了正确的compileOptions。以下代码使用API​​ 23在设备上编译并运行时没有错误

TemporalAccessor ta = null;
Instant i;
Date date = null;
try {
    int loc = 0;
    if ((loc = publishedDate.indexOf("+")) > 0) {
        // Offset time given
        publishedDate = adjustTimeFormat(publishedDate,loc);
        ta = DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(publishedDate);
        i = Instant.from(ta);
    } else if ((loc = publishedDate.indexOf("-")) > 0) {
        publishedDate = adjustTimeFormat(publishedDate,loc);
        ta = DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(publishedDate);
        i = Instant.from(ta);
    } else if (publishedDate.contains("Z")) {
        i = Instant.parse(publishedDate);
    } else {
        //
        ta = DateTimeFormatter.ISO_DATE.parse(publishedDate);
        i = Instant.from(ta);
    }
    date = Date.from(i);
} catch (Exception e) {
    ta = null;
}
if (ta == null) {
    date = new Date();
}
return date;

但是,lint将其中许多行标记为“需要API级别26(当前最小值为21)”

我认为在实行减贫的前提下,应该允许这样做吗?这是皮棉虫吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)