如何使用 eclipse adt 向 android 依赖项添加新库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20355971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:43:48  来源:igfitidea点击:

How do I add a new library to android dependencies using eclipse adt?

androideclipseandroid-layoutandroid-fragmentsandroid-library

提问by cYrixmorten

I am trying to add external library to android dependancies using eclipse adt. I have a couple of libraries like pull to refresh etc in there. But everytime I add a new library jar file it shows outside of the android dependancies library folder. How do I make it such that it is coupled with the other libraries as a part of android dependancies library. Here's what I did so far: Project> Properties> java build path > libraries> add jars ( also tried adding external jars), but it always showed my new jar file independantly, i want it to be a part of android dependancies). any clue? Here's a screen shot, I would like to add it as a part of android dependencies:

我正在尝试使用 eclipse adt 将外部库添加到 android 依赖项。我有几个库,比如 pull to refresh 等。但是每次我添加一个新的库 jar 文件时,它都会显示在 android 依赖库文件夹之外。我如何使它与其他库结合作为 android 依赖库的一部分。这是我到目前为止所做的:项目> 属性> java 构建路径> 库> 添加 jar(也尝试添加外部 jar),但它总是独立地显示我的新 jar 文件,我希望它成为 android 依赖项的一部分)。任何线索?这是一个屏幕截图,我想将其添加为 android 依赖项的一部分:

enter image description here

在此处输入图片说明

回答by cYrixmorten

I still do not get why that is important to you.

我仍然不明白为什么这对你很重要。

However, when you reference a library project: rightclick project->properties->Android->Add then the jar goes into Android Dependencies.

但是,当您引用库项目时:右键单击项目->属性->Android->添加,然后 jar 进入 Android 依赖项。

If you add the jar directly to your project under libs or using build path, then it goes under Android Private Libraries.

如果您将 jar 直接添加到 libs 下的项目或使用构建路径,则它位于 Android Private Libraries 下。

Both methods works but referencing a library project can have benefits if you want to alter the code of the library during development.

这两种方法都有效,但如果您想在开发过程中更改库的代码,引用库项目可能会有好处。

回答by Ivan

In my case I had the following in my project.properties file

就我而言,我的 project.properties 文件中有以下内容

target=android-18
proguard.config=proguard.cfg
android.library=false
android.library.reference.1=..\com_facebook_android

android.library.reference.2=../actionbarsherlock

After I changed the last line to

在我将最后一行更改为

android.library.reference.2=..\actionbarsherlock

actionbarsherlock.jar appeared in the Android Dependancies and I could run my app without the java.lang.noclassdeffounderror exception

actionbarsherlock.jar 出现在 Android Dependancies 中,我可以在没有 java.lang.noclassdeffounderror 异常的情况下运行我的应用程序