如何在包含多个项目的外部库未做多个副本的Andr​​oid的Java [英] How to include external libraries in multiple projects without making multiple copies android java

查看:206
本文介绍了如何在包含多个项目的外部库未做多个副本的Andr​​oid的Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的 afreechart edu.emory.mathcs.jtransforms org.afree.chart 在许多不同的活动,我为Android编写。我有麻烦了大量配置得到每一个新的项目,所以我可以

I am using afreechart and edu.emory.mathcs.jtransforms and org.afree.chart in numerous different activities I am writing for Android. I have a tremendous amount of trouble getting each new project configured so that I can


  1. 从库中看到类我写在Eclipse IDE code。

  2. 附见源这些类

  3. 查看这些类的javadoc附

  4. 请参阅这些类的.class文件,当我尝试运行我的活动。

我现在做的是使该.jar,DOC src和的.properties每个我使用库的副本。我这四件事复制到本地lib文件夹为我创造每一个项目(每个活动)。

What I do now is make a copy of the .jar, doc src and .properties for each library I use. I copy those four things into the local lib folder for each project (one per activity) I am creating.

我一定是失去了一些东西简单。很明显,我应该有这些库,用自己的文档src和的.properties,在一个位置,那我应该能够引用在使用这些库每个项目的位置。但我还没有搞清楚怎么还没有做到这一点。请告诉我怎么样。

I must be missing something simple. It seems obvious that I should have these libraries, with their doc, src, and .properties, in one location, and that I should be able to reference that location in each project that uses those libraries. But I haven't figure out yet how to do that. Please tell me how.

如果有一种方法来定义一组罐和相关的SRC&安培;这将自动总是被任何新的Eclipse项目我做的搜索文档,这将是更好的。

If there is a way to define a set of jars and associated src & doc that will automatically and always be searched by any new eclipse project I do, that would be even better.

编辑后添加有关外部利布斯答案:

EDIT ADDED After answers about external Libs:

因此​​,我们确实我没把jtransforms-2.4.jar外部目录中。在同一个目录下我把src和文档的包,一个文件,其中有doc和src中的本地文件的文档和src项指向jtransforms-2.4.properties。我加他们为外部JAR我的构建路径。

So indeed I did put jtransforms-2.4.jar in an external directory. In that same directory I put the src and doc for the package, and a file jtransforms-2.4.properties with a doc and src entry pointing at the local files with doc and src. I added them to my build path as external jar.

1),Eclipse IDE的肯定发现了的.jar的类和标记没有为失踪人。
2)文档和在src被示出为不附着。 如何,我把DOC和与库一起SRC信息,使他们自动显示每一个地方我联系罐子作为外部罐子?
3)当我试图运行的应用程序,我得到了在罐子中的所有类NoClassDefFound错误。也就是说,Eclipse IDE中可以找到外部的lib这些类,但他们没能到的类路径应用程序。

1) Eclipse IDE certainly found the classes in the .jar and flagged nothing as missing. 2) The doc and the src were shown as not attached. How do I put doc and src info along with the library so they automatically show up every place I link the jar as an external jar? 3) When I attempted to run the app, I got "NoClassDefFound errors for all the classes in the jar. That is, Eclipse IDE could find these classes in the external lib, but they did not make it in to the class path of the app.

摘要:让外部罐技术一直未能三分之二的三个重要方面:
1)没有src和文档显示为附着在Eclipse IDE中
2)不提供更新的类路径的应用程序。

SUMMARY: so the "external jar" technique has failed in two out of three important respects: 1) No src and doc show up as attached in eclipse IDE 2) do not provide updated class paths to the App.

最后:当我复制的jar,的.properties,文档和源代码在我的项目的lib文件夹,并取消了外部JAR参考,一切都完美。

FINALLY: when I copied the jar, .properties, doc and src in to the lib folder of my project, and removed the external jar reference, everything worked perfectly.

所以我重申,我原来的问题,给出的答案(添加到构建路径外部罐)并没有解决任何问题。

SO I reiterate my original question, the answers given (add to build path as external jar) did not solve anything.

推荐答案

他们在这里的关键字是外部的。您可以在无需本地lib文件夹让他们到你的项目中添加库。你只需将其添加为外部档案。

They keyword here is external. You can add library to your project without having them in your local lib folder. You just need to add them as "External Archives".

您还可以添加,并通过项目的性质改变它们。结果
虽然我不认为这是一个好主意,一些图书馆的添加到您创建的每一个项目,可能有一个剧本,但国际海事组织它不是一个内置的功能。结果
修改结果
好吧,这不是真的内置,看起来退出的hackish给我,但<一href=\"http://stackoverflow.com/questions/9873152/how-to-attach-javadoc-or-sources-to-jars-in-libs-folder\">this线程可能对你有用。它包含一个方法,你可以通过属性文件ADRESS你的问题。你只需要一次创建这个文件,并把它添加到您的项目。因此,这是半自动的)结果
但我认为这个解决方案比将它添加到每一个项目,因为你不应该需要所有这些库的每一次更好的...结果
修改2:(后你的)
至于第1点:结果
可能有不同的原因库不工作作为外部库:

You can also add and alter them via your project's properties.
Although I dont think it's a good idea, to add some librarys to every project you create, there may be a script for that, but imo it's not a build-in function.

Well, it's not really built-in and it looks quit hackish to me, but this thread may be useful to you. It contains a way you can adress your problems via a properties file. You just need to create this file once and add it to your projects. So this is semi-automatic ;)
But I think this solution is better than adding it to every project since you shouldn't need all those libraries every single time...
EDIT 2: (after yours) As to the 1st point:
There may be different reasons why the library doesnt work as an external library:


  1. 您没有正确的权限在该文件夹

  2. 您在你的classpath库的多个版本。删除其他引用,然后再次尝试

正如我前面提到的,只是将其添加到类路径不会自动提供链接索马里红新月会和文档。我建议以上检查出的链接。有了这种技术,你可能半自动实现自己的目标。结果
但是,如果你google一下外部罐子和eclipse你遇到有同样的问题,你有很多的人。所以,通常它应该工作的开箱。你介意更新您的Eclipse?
另一个编辑:
我完全忘了你写一个Android应用程序的事实。嗯,这是一个相当特殊的情况。有的有关此问题的主题。也许你也应该看看<一个href=\"http://stackoverflow.com/questions/7994715/noclassdeffounderror-on-external-library-project-for-android\">this 之一。随着ADT17将您库库被触发自动导入。这就是为什么是这样工作适合你。(当你把它放在/库)

As I already mentioned, just adding it to the class path doesn't automatically provides linked srcs and docs. I recommend checking out the link above. With that technique you might achieve your goal semi-automatically.
But if you google about external jars and eclipse you encounter many people having the same issue as you have. So normally it should work out of the box. Would you mind updating your eclipse? Another edit: I totally forgot about the fact you are writing an Android app. Well, that's quite a special case. There many topics about this issue. Maybe you should also check out this one. With ADT17 placing you library in libs is triggering an automatic import. That's why it works this way for you.(When you place it in /libs)

这篇关于如何在包含多个项目的外部库未做多个副本的Andr​​oid的Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆