我需要從JRE7庫中添加一些JAR到我的Android項目。但例如rt.jar
與android.jar
從的Adroid 2.2 SDK衝突,所以我得到這個錯誤:重新包裝.jar文件
Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library.
This is often due to inadvertently including a core library file in your application's project, when using an IDE (such as Eclipse). If you are sure you're not intentionally defining a core class, then this is the most likely explanation of what's going on.
However, you might actually be trying to define a class in a core namespace, the source of which you may have taken, for example, from a non-Android virtual machine project. This will most assuredly not work. At a minimum, it jeopardizes the compatibility of your app with future versions of the platform. It is also often of questionable legality.
If you really intend to build a core library -- which is only appropriate as part of creating a full virtual machine distribution, as opposed to compiling an application -- then use the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact building an application, then be forewarned that your application will still fail to build or run, at some point. Please be prepared for angry customers who find, for example, that your application ceases to function once they upgrade their operating system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a core package, then the easiest safe alternative you have is to repackage that code. That is, move the classes in question into your own package namespace. This means that they will never be in conflict with core system classes. JarJar is a tool that may help you in this endeavor. If you find that you cannot do this, then that is an indication that the path you are on will ultimately lead to pain, suffering, grief, and lamentation.
我知道已經有關於它的幾個線程之類的東西JarJar,OneJar或FatJar可能是爲我好。但我不知道如何使它們中的任何一個都起作用,並且文檔沒有真正地說清楚(對我而言)。我猜他們使用Ant命令,但我一直使用Eclipse內置的構建器,現在我不知道如何使用Ant和上面提到的任何一種。
所以我的問題是:如何重新包裝這個rt.jar,以便我可以在我的Android項目中進行編譯?
謝謝!
編輯:
好了,我想達到的目標是創建一個.jar,它可以開發Android應用程序中使用(簡化一些功能,其實並不重要)。但我也希望能夠將標準Java項目添加到同一個.jar文件中,以便在其中使用一些函數。它看起來像這樣: 編寫應用程序的人將這個.jar添加到他的Java項目 - >它使他能夠生成某些文件(需要互聯網來完成) - >這些生成的文件然後被添加到Android項目 - >稍後在有人使用此Android應用程序時,這些文件提供某些功能而不使用互聯網(脫機)。
你真的不應該包括來自JRE'rt.jar'到Android項目。你之後使用核心Android SDK無法實現的功能是什麼? – 2012-04-25 12:23:14
相關問題:http://stackoverflow.com/questions/839435/android-core-library-error – 2013-03-10 09:11:07