我们的主要关注点是基于 Java 的桌面应用程序。我们应用程序的数据使用 Hibernate 存储在 H2 数据库中。H2 数据库以服务器模式运行,以便其他客户端可以连接到它。
是否可以构建一个 Android 应用程序来查看托管在服务器上的数据。当我在我的 android 应用程序 libs 文件夹中包含休眠 jar 时,我收到以下错误。
[dx] trouble processing "javax/transaction/Transaction.class":
[dx]
[dx] Ill-advised or mistaken usage of a core class (java.* or javax.*)
[dx] when not building a core library.
[dx]
[dx] This is often due to inadvertently including a core library file
[dx] in your application's project, when using an IDE (such as
[dx] Eclipse). If you are sure you're not intentionally defining a
[dx] core class, then this is the most likely explanation of what's
[dx] going on.
[dx]
[dx] However, you might actually be trying to define a class in a core
[dx] namespace, the source of which you may have taken, for example,
[dx] from a non-Android virtual machine project. This will most
[dx] assuredly not work. At a minimum, it jeopardizes the
[dx] compatibility of your app with future versions of the platform.
[dx] It is also often of questionable legality.
[dx]
[dx] If you really intend to build a core library -- which is only
[dx] appropriate as part of creating a full virtual machine
[dx] distribution, as opposed to compiling an application -- then use
[dx] the "--core-library" option to suppress this error message.
[dx]
[dx] If you go ahead and use "--core-library" but are in fact
[dx] building an application, then be forewarned that your application
[dx] will still fail to build or run, at some point. Please be
[dx] prepared for angry customers who find, for example, that your
[dx] application ceases to function once they upgrade their operating
[dx] system. You will be to blame for this problem.
[dx]
[dx] If you are legitimately using some code that happens to be in a
[dx] core package, then the easiest safe alternative you have is to
[dx] repackage that code. That is, move the classes in question into
[dx] your own package namespace. This means that they will never be in
[dx] conflict with core system classes. JarJar is a tool that may help
[dx] you in this endeavor. If you find that you cannot do this, then
[dx] that is an indication that the path you are on will ultimately
[dx] lead to pain, suffering, grief, and lamentation.
[dx]
[dx] 1 error; aborting
有两个必需的 Hibernate 库使用 javax 命名空间(hibernate-jpa-2.0-api.1.0.1-Final.jar 和 jboss-transaction-api_1.1_spec-1.0.0.Final.jar)。
- 它尝试将所有库组合到 .apk 中并抛出异常,因为它使用保留的命名空间找到了一个类。
- 类可能与作为 Android/Java 一部分的系统(核心)类发生冲突。
我相信这个错误/警告的最后一段适用于我正在尝试做的事情。
- 使用像 JarJar 这样的工具会有帮助吗?
- 重新打包代码如何与许可一起使用?
- 重新打包所有代码会很困难吗?
- 为什么第三方会在 javax 中创建一个包?
编辑:我正在使用 ant 通过自动生成的构建文件和命令“ant debug”来编译 Android 项目。