Android的IllegalAccessError java.util.concurrent.TimeUnit.toHours [英] Android IllegalAccessError java.util.concurrent.TimeUnit.toHours

查看:145
本文介绍了Android的IllegalAccessError java.util.concurrent.TimeUnit.toHours的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么会变成这样:

long diffInMis = date2.getTime() - date.getTime();
diffInHour = TimeUnit.MILLISECONDS.toHours(diffInMis);

抛出这个:

java.lang.IllegalAccessError:试图访问方法
  java.util.concurrent.TimeUnit.toHours:(Z)V

java.lang.IllegalAccessError: tried to access method java.util.concurrent.TimeUnit.toHours:(Z)V

我在开发者控制台的错误,无法重现它。
通过知道,我只是做数学题我自己,但我很好奇。

I have that error in the developer console and cannot reproduce it. By know i just do the math on my own, but I am curious.

设备:HTC传奇的Andr​​oid 2.2

Device: HTC Legend Android 2.2

答:在的TimeUnit API&LT丢失; 9

Answer: TimeUnit missing in API < 9

推荐答案

Java 5中没有的 toHours 的,但是的 Java 6中确实。我的猜测是,你正在使用在运行时版本的TimeUnit类不包括toHours。当你的code不能从参考的位置访问字段或方法,这种异常的发生。

Java 5 didn't have toHours, but Java 6 does. My guess is you're using a version of the TimeUnit class at runtime that doesn't include toHours. This kind of exception occurs when your code cannot access the field or method from the location of your reference.

这篇关于Android的IllegalAccessError java.util.concurrent.TimeUnit.toHours的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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