Android 错误“无法解析虚拟方法 java/beans/PropertyDescriptor”是否有解决方法?

发布于 2024-10-28 06:34:32 字数 609 浏览 5 评论 0原文

我正在尝试在 Android 应用程序中使用第三方 jar 文件。我已经能够很好地使用 jar 文件中的一些类。但是,其中一个类引用了 dalvik 虚拟机似乎不支持的一些 Java 类。以下是我在 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.

dalvik 似乎不支持与内省和反射相关的 Java 类。我想了解两件事。 dalvik 是否有计划在不久的将来支持这一点?其次,有没有人有解决这个问题的建议?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

待天淡蓝洁白时 2024-11-04 06:34:32

dalvik 似乎不支持与内省和反射相关的 Java 类。

AFAIK,不是一揽子的。 Android 核心团队的目标之一是保持固件较小,以降低设备成本。这样做的一个副作用是仅包含他们认为必不可少的 java.*javax.* 中的类。最初,Android 中不存在 java.beans.*;现在,只有一些类和接口可用,但不是整个包。

近期有计划在 dalvik 中支持此功能吗?

当我们其他人知道时,您就会知道,也就是说,只有当它出现在版本中时。

其次,有没有人有解决此问题的建议?

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

  1. 从 Apache Harmony 获取必要的 java.beans 类并将它们放入您的项目中
  2. 将它们重构为单独的包(例如,bondy.beans),因为如果您尝试将 java.beans 类加载到您的项目中,Android 不会很喜欢
  3. 修改第三方 JAR 以使用您的类的重构版本

有可能 < a href="http://code.google.com/p/jarjar/" rel="noreferrer">jarjar 也可以对此做一些事情——我还没有使用过这个工具,不知道其能力的范围。

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:

  1. Grab the necessary java.beans classes from Apache Harmony and put them in your project
  2. 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
  3. 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.

我们的影子 2024-11-04 06:34:32

Apache Harmony 已经退役很长时间了。我正在使用 openbeans。它为我解决了所有问题。

Apache harmony is retired for a long time now. I am using openbeans. And it solves all the problem for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文