是否有可能增加一个库项目的JAR文件,并在另一个项目中利用其资源? [英] Is it possible to add a JAR file of a library project and use its resources in another project?
问题描述
我想添加一个JAR到LIBS另一个项目和再利用的资源从JAR该项目内,但我正在
I am trying to add a JAR to libs for another project and then use resources from the JAR inside of that project but I am getting
java.lang.NoClassDefFoundError: com.xxxxx.dylib.R$drawable.
该JAR内容是:
The JAR contents are:
com.xxxxx.dylib
res
res.layout
res.menu
res.values
在库项目添加为一个依赖它的工作原理,但在使用JAR没有R.java产生。我相信这就是问题所在。是否有可能利用的资源从项目中的JAR?
When the library project is added as a dependency it works but when the JAR is used there is no R.java generated. I believe this is the problem. Is it possible to use resources from a jar within a project?
推荐答案
资源不能被打包成罐子。这不是指资源的纯Java的类可以打包成jar文件。
Resources cannot be packaged into jar. Pure java class that do not refer to resources can be packaged into jars.
您需要做,你需要引用作为库项目,然后在指你的Android项目相同的项目。
You need to make the project that you need to refer to as a library project and then refer the same in your android project.
http://developer.android.com/tools/projects/index.html
如果你想使用命令行
http://developer.android.com/tools/projects/projects- cmdline.html
如果您使用eclipse按照下面的链接。
If your using eclipse follow the below link.
http://developer.android.com/tools/projects/projects- eclipse.html
您可以右键单击要引用,转到物业项目。选择Android和检查是图书馆。
You can right click on the project that you want to refer, goto properties. Choose Android and check Is Library.
现在指在你的Android项目库项目。
Now to refer the library project in your android project.
右键点击您的Android项目,转到物业,选择Android的,单击添加浏览库项目和相同的。
Right click on your android project, goto properties, choose android, click add browse the library project and the same.
这篇关于是否有可能增加一个库项目的JAR文件,并在另一个项目中利用其资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!