建库项目 [英] Build library project
本文介绍了建库项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所有。 我创建了一个Android库项目,它是完美的作品,当我从主项目引用它。但是,当我建库项目除了它不包含R.java和资源。有没有办法建立一个库项目的资源和R.java?
all. I've created an android library project and it's works perfectly when i reference it from main project. But when i build the library project apart it doesn't contains R.java and resources. Is there way to build a library project with resources and R.java?
推荐答案
这是不可能的了。
现在,我们可以通过以下步骤创建一个二进制只有库项目:
Now we can create a binary-only library project via the following steps:
- 创建一个Android库项目,与源$ C $ c和这样的 - 这是你的主项目,从中你将创建一个版本 库项目分布
- 编译Java源代码(例如,蚂蚁编译),并把它变成一个JAR文件
- 创建一个分发的Android库项目,用相同的 资源作为主库项目,但没有源$ C $ C
- 把JAR文件中分发的Android库项目的库/ 目录 由此产生的分配的Android库项目将拥有一切一 主体工程需要,只是没有源$ C $ C。
- Create an Android library project, with your source code and such – this is your master project, from which you will create a version of the library project for distribution
- Compile the Java source (e.g., ant compile) and turn it into a JAR file
- Create a distribution Android library project, with the same resources as the master library project, but no source code
- Put the JAR file in the distribution Android library project's libs/ directory The resulting distribution Android library project will have everything a main project will need, just without the source code.
目前在这个解决方案的一些限制:
There is some restrictions in this solution:
- 我们还是要出货的资源。
- 我们要改写我们的code,以避免使用R.值,因为它们 将是错误的。我们将使用查找所有的资源标识 getResources()。则getIdentifier()和/或反射。
- We still have to ship the resources.
- We have to rewrite our code to avoid using R. values, as they will be wrong. We will have to look up all resource IDs using getResources().getIdentifier() and/or reflection.
这篇关于建库项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文