问题描述
我想单独一个Java库,即无需库纳入每个服务的APK用于多个机器人服务,为可以由这些独立的服务被加载动态或共享库。
I'm trying to separate a Java Library, that is used by multiple Android "services", into a dynamic or shared library that can be loaded by those independent services without having the library included into the APK of each service.
我知道有这样做的,如创建一个Android服务或使用DexLoader与思考,但我想,以避免改变库源的不同方式。相反,我试图建立它和我的设备上(实际上延长了提供的Android API)安装。
I know there are different ways of doing this like creating an Android Service or using DexLoader and Reflection but I'm trying to avoid changing the source of the library. Instead I'm trying to build it and install it on my device (essentially extending the provided android API).
下面是一个非常类似的问题是仍然无人应答:<一href="http://stackoverflow.com/questions/8733530/create-android-apps-in-eclipse-sharing-common-library?answertab=active#tab-top">Create Android应用程序在Eclipse中共享公共库
The following is a very similar question which is still unanswered:Create Android apps in Eclipse sharing common library
我知道这是什么谷歌并不想在网上公开,以便查找信息是非常困难的。
I know this is something Google doesn't want to disclose so finding information online is extremely difficult.
到目前为止,我已经试过在框架目录放置一个简单的Hello World程序,并建立它成功地创造了一个罐子我的计划。然后,我在产品/ core.mk加入我的包,另外根据API添加我的包定义/ 10.xml之后,我跑了让SDK,这导致了以下错误消息:
So far I've tried placing a simple "Hello World" program under the frameworks dir and build it which successfully created a jar for my program. Then I added my package in product/core.mk and in addition added my package definition under api/10.xml after which I ran "make sdk" which resulted in the following error message:
******************************
You have tried to change the API from what has been previously released in
an SDK. Please fix the errors listed above.
******************************
make: *** [out/target/common/obj/PACKAGING/checkapi-last-timestamp] Error 38
作为一种变通方法我加我包成public_api.xml文件,输出目录,它以某种方式动态地在构建过程中产生的内部。有了这个解决办法的SDK是建立没有任何错误(但如果我这样做清洗一遍我不得不再次修改public_api.xml,因为它会因清洗去除)。但是,当我尝试导入和使用我的包在任何地方它仍然说,我的包不存在
As a workaround I added my package into "public_api.xml" file, inside the out directory, which is somehow dynamically created during the build process. With this workaround the SDK is built with no errors (although if I do clean again I'll have to modify the public_api.xml again because it will be removed due to clean). However, when I try to import and use my package anywhere it still says that my package "does not exist"
任何帮助将大大AP preciated!谢谢!
Any help will be greatly appreciated! Thank you!
推荐答案
终于想通了。该解决方案被证明是非常简单的!
Finally figured it out. The solution turns out to be very simple!
将库在框架/基文件夹,并确保所有源$ C $ c是在Java目录下,像这样:
Place your library in the frameworks/base folder and make sure all your source code is inside under java directory like so:
../frameworks/base/HelloWorld/java/<source files and folders>
修改 core.mk位于文件建立/目标/产品/ 以包括你的包在列表中。这将增加的HelloWorld库的框架:
Edit core.mk file located under build/target/product/ to include your package in the list. This will add HelloWorld library to the framework:
PRODUCT_PACKAGES := \
bouncycastle \
:
:
DefaultContainerService \
Bugreport \
HelloWorld
修改 pathmap.mk位于建立/核心/ 以包括您在列表目录下文件。这将增加的HelloWorld库中的android.jar
Edit pathmap.mk file located under build/core/ to include your directory in the list. This will add HelloWorld library to the android.jar
FRAMEWORKS_BASE_SUBDIRS := \
$(addsuffix /java, \
core \
graphics \
location \
media \
opengl \
sax \
telephony \
wifi \
vpn \
keystore \
voip \
HelloWorld \
)
完成。重建Android和它不应该抱怨,你的库添加到 framework.jar !
我希望这有助于。
这篇关于动态链接到一个共享的Java库中的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!