是否有变通为Android错误"无法解析虚方法的Java /豆/ PropertyDescriptor与"?错误、方法、Android、QUOT

2023-09-06 02:15:15 作者:少年╭白了头〃

我想在Android应用程序中使用第三方JAR文件。我已经能够蛮好用一些类的jar文件。然而,类之一引用不出现由Dalvik虚拟机支持一些Java类。这些都是一些我看到的LogCat中的误区:

 无法找到签名的Java /豆/ PropertyDescriptor与引用的类。
无法解析的虚拟方法的Java /豆/ PropertyDescriptor.getName()。
无法解析的虚拟方法的Java /豆/ PropertyDescriptor.getReadMethod()。
无法解析静态方法的Java /豆/ Introspector.getBeanInfo()。
无法解析异常类的Java /豆/ IntrospectionException在。
 

看来,有关内省和反思的Java类不支持的Dalvik。我想找出两件事情。那是一个计划,以支持这一点的Dalvik在不久的将来?其次,没有任何人有一个建议周围的工作,将解决这个问题?

解决方案   

看来,有关内省和反思的Java类不支持的Dalvik。

不是在毯子的基础上,AFAIK。核心Android团队的一个目的是保持固件小,以减少设备的成本。这方面的一个副作用是只包括 Java类。* 的javax。* ,他们觉得是必要的。本来,无 java.beans中的* 存在于Android的。现在,一些类和接口都可以,但不能全包。

  

那是一个计划,以支持这一点的Dalvik在不久的将来?

您会知道什么时候我们其余的人都知道,这是说,只有当它出现在一个版本。

  

其次,没有任何人有一个建议周围的工作,将解决这个问题?

Android 全面解析熟悉而陌生 的 Application 类使用

如果第三方JAR是一个开源项目:

抢必要的的java.beans 类来自Apache和谐,把他们在你的项目 在重构成一个单独的包(例如, bondy.beans ),由于Android不会喜欢的多,如果你尝试加载的java.beans 类到您的项目 修改第三方JAR使用类的重构版本

这可能是 jarjar 能为此做些什么,以及 - 我还没用过该工具不知道它的功能范围。

I am trying to use a third party jar file within an Android application. I have been able to use some of the classes in the jar file just fine. However, one of the classes references some Java classes that don't appear to be supported by the dalvik vm. These are some of the errors I am seeing in LogCat:

Unable to find class referenced in signature java/beans/PropertyDescriptor.
Unable to resolve virtual method java/beans/PropertyDescriptor.getName().
Unable to resolve virtual method java/beans/PropertyDescriptor.getReadMethod().
Unable to resolve static method java/beans/Introspector.getBeanInfo().
Unable to resolve exception class java/beans/IntrospectionException.

It appears that Java classes related to introspection and reflection are not supported by dalvik. I would like to find out two things. Is that a plan to support this in dalvik in the near future? Secondly, does anyone have a suggestion for a work around that would get around this problem?

解决方案

It appears that Java classes related to introspection and reflection are not supported by dalvik.

Not on a blanket basis, AFAIK. One objective of the core Android team is to keep the firmware small, to reduce the cost of devices. One side-effect of this is to only include classes from java.* and javax.* that they feel are essential. Originally, none of java.beans.* existed in Android; now, a few classes and interfaces are available, but not the whole package.

Is that a plan to support this in dalvik in the near future?

You will know when the rest of us know, which is to say, only if it shows up in a release.

Secondly, does anyone have a suggestion for a work around that would get around this problem?

If the third-party JAR is an open source project:

Grab the necessary java.beans classes from Apache Harmony and put them in your project Refactor them into a separate package (e.g., bondy.beans), since Android will not like it much if you try loading java.beans classes into your project Modify the third-party JAR to use your refactored edition of the classes

It is possible that jarjar can do something about this as well -- I have not yet used the tool and do not know the extent of its capabilities.