不能在Eclipse中向Android项目添加库。

时间:2023-01-17 11:05:17

I am trying to add a Library to an existing project inside eclipse. I am keeping the Project Folder itself and the Library Folder in a folder marked "ANDROID" on my desktop. When I try to Import > Existing Code into Workspace > Select "ANDROID".. the only project that gets added is the App itself and NOT the library. I even try to add the library on its own and it will show up on the import list but will not have a "ticked box" with the option of "Finish". I even right clicked my App - Properties > Android > and noticed that the library is there with a red "X" and does not allow me to search for a new library. What am I doing wrong? This Identical App and library is working with the same version of eclipse for a friend and not me.

我正在尝试将一个库添加到eclipse中现有的项目中。我将项目文件夹和库文件夹保存在我桌面上的“ANDROID”文件夹中。当我尝试将>现有代码导入工作区>选择“ANDROID”时。唯一添加的项目是应用程序本身,而不是库。我甚至尝试添加自己的库,它会出现在导入列表中,但不会有一个带有“Finish”选项的“ticked box”。我甚至右键单击了我的应用程序> Android >,注意到库中有一个红色的“X”,不允许我搜索一个新的库。我做错了什么?这个相同的应用程序和库正在为一个朋友而不是我使用同一个版本的eclipse。

4 个解决方案

#1


22  

Make sure that the libraries and the project are at the same place, i.e.

确保库和项目处于相同的位置,即

  1. Copy the libraries in the same folder as your project
  2. 复制与项目相同的文件夹中的库。
  3. Import the libraries (file > Import > Existing Project in workspace)
  4. 导入库(文件>导入工作区中现有项目)
  5. Open properties of library > Android and select Is Library
  6. 开放的属性库> Android和选择是图书馆。
  7. Open project properties > Android > Add (library)
  8. 开放项目属性> Android > Add(库)
  9. Select the library
  10. 选择库
  11. save the properties
  12. 保存属性

If this does not work for you copy the jar files from its lib folder and paste it in the projects lib. This should only be done if the above method doesn't work

如果这并不适用于您从其lib文件夹中复制jar文件并将其粘贴到projects lib中,那么只有在上面的方法不起作用时才会这样做。

#2


3  

Import Library project in eclipse . Then right click on project and go to properties->Android (Menu on left side) --> At the bottom(below project build target) you will see a check box named is Library Check that box. Now you've made your project a library .

在eclipse中导入库项目。然后右键点击项目,进入属性->Android(左侧菜单)->在底部(在项目构建目标下方),你会看到一个名为Library check的复选框。现在你已经把你的项目变成了一个图书馆。

Then in your orignal project where you want to add library go again to to properties->Android (Menu on left side) --> At the bottom(below project build target) Click add button and you will find that library project visible.

然后,在您想要添加库的原始项目中,再次添加到属性->Android(左侧菜单)—底部的>(在项目构建目标下)单击add按钮,您将发现该库项目可见。

#3


0  

This happens when you import the project from some location. If we import some project then it doesn't refer to the supporting library of that workspace. So always check the check box( copy projects to workspace) Go to file>import project>browse>select a project>Check the copy project into workspace. Hope it solve the issue.

当您从某个位置导入项目时,就会发生这种情况。如果我们导入某个项目,那么它就不会引用该工作区的支持库。因此,要经常检查复选框(复制项目到工作区)到文件>导入项目>浏览>选择一个项目>检查复制项目到工作区。希望能解决这个问题。

#4


0  

A late answer, although I thought of giving an in-depth answer to this question.

一个很晚的回答,尽管我想对这个问题做一个深入的回答。

  1. First switch your folder structure from Android to Project.
  2. 首先将文件夹结构从Android切换到项目。

不能在Eclipse中向Android项目添加库。

  1. Now search for the libs folder inside app - build folder.
  2. 现在在app - build文件夹中搜索libs文件夹。

不能在Eclipse中向Android项目添加库。

  1. Once you have pasted the .jar file inside libs folder. Right click on the jar file and at end click on Add as library. This will take care of adding compile files('libs/library_name.jar') in build.gradle
  2. 一旦您将.jar文件粘贴到libs文件夹中。右键单击jar文件,最后单击Add作为库。这将负责在build.gradle中添加编译文件('libs/library_name.jar')。

不能在Eclipse中向Android项目添加库。

Now you can start using the library in your project.

现在您可以开始使用项目中的库了。

#1


22  

Make sure that the libraries and the project are at the same place, i.e.

确保库和项目处于相同的位置,即

  1. Copy the libraries in the same folder as your project
  2. 复制与项目相同的文件夹中的库。
  3. Import the libraries (file > Import > Existing Project in workspace)
  4. 导入库(文件>导入工作区中现有项目)
  5. Open properties of library > Android and select Is Library
  6. 开放的属性库> Android和选择是图书馆。
  7. Open project properties > Android > Add (library)
  8. 开放项目属性> Android > Add(库)
  9. Select the library
  10. 选择库
  11. save the properties
  12. 保存属性

If this does not work for you copy the jar files from its lib folder and paste it in the projects lib. This should only be done if the above method doesn't work

如果这并不适用于您从其lib文件夹中复制jar文件并将其粘贴到projects lib中,那么只有在上面的方法不起作用时才会这样做。

#2


3  

Import Library project in eclipse . Then right click on project and go to properties->Android (Menu on left side) --> At the bottom(below project build target) you will see a check box named is Library Check that box. Now you've made your project a library .

在eclipse中导入库项目。然后右键点击项目,进入属性->Android(左侧菜单)->在底部(在项目构建目标下方),你会看到一个名为Library check的复选框。现在你已经把你的项目变成了一个图书馆。

Then in your orignal project where you want to add library go again to to properties->Android (Menu on left side) --> At the bottom(below project build target) Click add button and you will find that library project visible.

然后,在您想要添加库的原始项目中,再次添加到属性->Android(左侧菜单)—底部的>(在项目构建目标下)单击add按钮,您将发现该库项目可见。

#3


0  

This happens when you import the project from some location. If we import some project then it doesn't refer to the supporting library of that workspace. So always check the check box( copy projects to workspace) Go to file>import project>browse>select a project>Check the copy project into workspace. Hope it solve the issue.

当您从某个位置导入项目时,就会发生这种情况。如果我们导入某个项目,那么它就不会引用该工作区的支持库。因此,要经常检查复选框(复制项目到工作区)到文件>导入项目>浏览>选择一个项目>检查复制项目到工作区。希望能解决这个问题。

#4


0  

A late answer, although I thought of giving an in-depth answer to this question.

一个很晚的回答,尽管我想对这个问题做一个深入的回答。

  1. First switch your folder structure from Android to Project.
  2. 首先将文件夹结构从Android切换到项目。

不能在Eclipse中向Android项目添加库。

  1. Now search for the libs folder inside app - build folder.
  2. 现在在app - build文件夹中搜索libs文件夹。

不能在Eclipse中向Android项目添加库。

  1. Once you have pasted the .jar file inside libs folder. Right click on the jar file and at end click on Add as library. This will take care of adding compile files('libs/library_name.jar') in build.gradle
  2. 一旦您将.jar文件粘贴到libs文件夹中。右键单击jar文件,最后单击Add作为库。这将负责在build.gradle中添加编译文件('libs/library_name.jar')。

不能在Eclipse中向Android项目添加库。

Now you can start using the library in your project.

现在您可以开始使用项目中的库了。