As I was writing up this question I managed to solve it so repeat it here for the benefit of others. Here is the initial problem:
在我写这个问题的时候,我设法解决了这个问题,所以为了别人的利益,在这里重复这个问题。这是最初的问题:
I have created a very simple library project which I want to reference in another project. I have done this previously with no problems so not really sure why it is not working this time. I have:
我创建了一个非常简单的库项目,我想在另一个项目中引用它。我之前做过这个没有问题,所以不知道为什么这次不工作。我有:
-
Flagged the library project via project properties. The
default.properties
file has this set :android.library=true
通过项目属性标记库项目。默认值。属性文件有这样的设置:android.library=true。
-
In my other project added reference to my library project via project properties. The
default.properties
file has the reference added as expected ieandroid.library.reference.1=K:/android_test_ws/applicationRegistrar
在我的另一个项目中,通过项目属性增加了对我的库项目的引用。默认值。属性文件的引用被添加到预期的ie android.library.reference.1=K:/android_test_ws/applicationRegistrar。
-
The green tick against the referenced library project starts off green and then changes to a red cross.
对引用的库项目的绿色标记从绿色开始,然后更改为一个红色的交叉。
This implies that there must be something wrong / missing from the library project but I don't know what. My library project on this occasion is MUCH simpler than the previous one I created.
这意味着在图书馆项目中肯定有一些错误/缺失,但我不知道是什么。我在这个场合的图书馆项目比我之前创建的那个要简单得多。
18 个解决方案
#1
159
OK Here is the solution which I found when I was looking for the default.properies file of the referencing project (not the library) in my file system. Although the referencing project was in the same eclipse workspace as the library project, the actual files were somewhere else in the file system ie they were'nt in the same parent folder of the library project. As soon as I placed the referencing project in the same physical folder as the library project it all went fine.
这是我在寻找默认值时找到的解。在我的文件系统中引用项目的属性文件(而不是库)。尽管引用项目位于与库项目相同的eclipse工作区中,但实际文件位于文件系统的其他地方,即它们不在库项目的相同父文件夹中。当我将引用项目放在与库项目相同的物理文件夹中时,一切都很顺利。
I guess that this must be something to do with android using ant underneath the covers.
我想这一定和android在幕后使用ant有关。
Edit: The project name needs match the folder name on the file system. What you are seeing in the Project Properties->Android->Library Reference is a relative file system path.
编辑:项目名称需要与文件系统上的文件夹名匹配。您在项目属性中看到的->Android->库引用是一个相对文件系统路径。
#2
11
Make Sure both the projects are present in same work space. To Do it, while importing the projects make sure "copy project into work space" check box is checked.
确保两个项目都存在于同一个工作空间中。要做到这一点,在导入项目时,要检查“复制项目到工作空间”复选框。
#3
10
the same problem will occur if your library project is in different partition from your current workspace. I have the same problem just now. My git source is in C: and I just move my workspace to D: and everything start to collapse.
如果您的库项目位于与当前工作区的不同分区中,则会出现相同的问题。我刚才遇到了同样的问题。我的git源代码是C:我把工作空间移动到D:一切都开始崩溃。
#4
4
Simplest way to get the library paths paths correct is to use the GUI from Eclipse to add the library as shown in the following screenshot and let Eclipse take care of putting the correct relative paths in project.properties. Its a common setup to have your library projects hosted at directories vastly different than your main projects that uses the library. This method will work if the "libary project" and the project using it are in the same eclipse "workspace" (they "need not" be in same parent folder):
获取库路径路径的最简单方法是使用Eclipse中的GUI来添加库,如下面的截图所示,让Eclipse负责在project.properties中放置正确的相对路径。这是一个常见的设置,使您的库项目驻留在与使用库的主要项目不同的目录中。如果“libary项目”和使用它的项目位于相同的eclipse“工作区”(它们“不需要”在相同的父文件夹中),则该方法将起作用。
#5
3
Please ensure that the library project is marked as "Is Library" - right click on the library project - properties - Android - mark the "Is Library" checkbox - in project.properties of the library project you should have a new entry:"android.library=true. Now add it into the project you want as described in the post below.(the post with image integrated - from Nilesh Pawar).
请确保图书馆项目被标记为“图书馆”-右击图书馆项目-属性- Android -标记“是图书馆”复选框-在项目中。库项目的属性应该有一个新条目:“android.library=true”。现在将其添加到您想要的项目中,如下所示。(由Nilesh Pawar提供图像集成的帖子)。
#6
#7
2
Yet another observation on the same issue.
另一个关于同样问题的观察。
For me the two projects where on the same parent folder, and were both local inside the workspace. Even then the issue was still happening.
对于我来说,这两个项目在同一个父文件夹中,并且都在工作区中。即便如此,这个问题仍在发生。
The I edited the "project.properties" file and put the absolute path(with forward slashes '/' for seperator) of the library project. Saved and closed it. Then went to the project properties dialog, removed the library(which was still showing the cross icon but with abs path) and added it back as usual. Surprisingly the issue is resolved, and the project compiles and runs.
我编辑了“项目”。属性“文件,并将该库项目的绝对路径(与前斜杠/“seperator”分隔开)。保存并关闭它。然后进入项目属性对话框,删除了库(它仍然显示交叉图标,但是带有abs路径),并像往常一样添加它。令人惊讶的是,这个问题已经解决了,并且项目编译并运行。
This is really strange and must be a bug with the ADT. I am using ADT version 20.0.2
这真的很奇怪,一定是ADT的bug。我使用的是ADT版本20.0.2。
#8
2
when developer referencing the facebook or any other library project then first of all clean the project from eclipse->project->clean project. that want allow the error of red cross in referencing screen.
当开发人员引用facebook或任何其他的库项目时,首先要清理eclipse->项目->clean项目中的项目。这就允许在引用屏幕上允许红色交叉的错误。
#9
2
For me, I just restart the eclipse and the added library works fine.
对我来说,我只是重新启动了eclipse,并且添加的库工作得很好。
I mean first time it showing red marks after adding the library project. Though eclipse main project and library project are in same workspace folder and no resources files are in outside of the project folder.
我的意思是第一次在添加了库项目后显示红色标记。尽管eclipse主项目和库项目位于相同的工作区文件夹中,并且没有资源文件在项目文件夹的外部。
So, you can try with to restart your eclipse. Happy coding....
因此,您可以尝试重新启动eclipse。快乐编码....
#10
1
Workaround for me was to
我的工作就是。
- Create a new workspace
- 创建一个新的工作区
- Import Library Project in that workspace
- 在该工作区中导入库项目。
- Import The desired project in that workspace
- 在该工作区中导入所需的项目。
- Having both project and library project the same target Android OS version
- 项目和库项目都有相同的目标Android OS版本。
- Reference library project in my project
- 在我的项目中参考图书馆项目。
solved my problem
解决了我的问题
#11
1
i had the same problem there when i try to change my workspace so this my solution:
当我试图改变工作空间时,我遇到了同样的问题,所以我的解决方案是:
- import and copy all project data including library project into workspace
- 导入和复制所有项目数据,包括库项目到工作区。
- delete the old project reference by Right-click on the project-->Properties-->Android-->Library, and select corrupted library(so that waht i call it) and choose Remove
- 删除旧的项目引用,右键单击项目——>属性——>Android——>库,并选择损坏的库(我称之为waht),然后选择Remove。
- clean project first (to refresh ur project properties)
- 清洁项目优先(刷新ur项目属性)
- go to library project Properties-->Android-->Library and check the is library if it does'nt click Apply then OK
- 转到库项目属性——>Android——>库,如果它不点击应用程序,就检查它的库。
- if the library project is library is already checked, first Unchecked it then Clean the library project after that do the Step 4 again
- 如果库项目已经被选中,首先检查它,然后在完成第4步之后清理库项目。
- go to project that u want the library are in then Right-click on the project-->Properties-->Android-->Library, Add then choose the library project (it should be there) and click Apply then OK
- 去到你想要图书馆的项目,然后右击项目——>属性——>Android——>库,然后选择库项目(它应该在那里),然后点击应用。
- if still doesn't appear clean the project once more time and that should do
- 如果仍然没有出现清理项目的时间和应该做的事情。
#12
1
Just restart your eclipse. It's solve my problem
只是重新启动eclipse。这是解决我的问题
#13
0
When you have a look at the reference-path before and after, it comes from i.e. "C:/workspace/mylib" and goes to "../../mylib" when copied to the correct location, quite interesting.
当你看一下之前和之后的参考路径,它来自于。"C:/workspace/mylib"然后去"../../mylib“当复制到正确的位置时,非常有趣。
#14
0
FYI,
通知你,
What worked for me was to delete the 'library' projects (the actual projects) from my workspace (without deleting the files), and then re-importing them using the wizard (import existing android project from source code).
我的工作是将“库”项目(实际项目)从我的工作空间中删除(不删除文件),然后使用向导重新导入它们(从源代码导入现有的android项目)。
#15
0
Thanks for posting the question. I had exactly the same problem while integrating Facebook with my Android application. I fixed the issue by moving my development project to the same Windows drive in which library project was located. Somehow Eclipse is unable to read the library project's location properly from default.properties file if it is in a different drive.
谢谢你提出这个问题。在整合Facebook和我的Android应用程序的同时,我也遇到了同样的问题。我将开发项目转移到与库项目相同的Windows驱动器上,从而解决了这个问题。某种程度上,Eclipse无法正确地从默认状态读取库项目的位置。属性文件,如果它在不同的驱动器。
#16
0
Similar to Sufi Khan's post I also solved this issue with a reboot. My case differed in that when I first accessed Properties->Android and added the library I got a lovely green checkmark. When I closed the dialog Eclipse was still showing class-not-found type errors. When I checked the properties again I saw the red X. But Mr. Kahn's solution (delete the bad lib, restart Eclipse, add the lib again) worked fine.
与Sufi Khan的帖子类似,我也通过重启来解决这个问题。当我第一次访问Properties->Android并添加了一个漂亮的绿色标记时,我的情况就不同了。当我关闭对话时,Eclipse仍然显示类未发现的类型错误。当我再次检查属性时,我看到了红色x,但是Kahn先生的解决方案(删除坏的lib,重新启动Eclipse,再添加lib)运行良好。
I'm using the 0702 version of the ADT bundle (starts with "cluster", rhymes with "duck").
我使用的是0702版本的ADT bundle(以“集群”开头,与“duck”押韵)。
#17
0
I followed the accepted answer but also had to make sure my "project.properties" file was readable.
我遵循了公认的答案,但也必须确保我的“项目”。属性文件是可读的。
If the file is readonly (checked into source control) eclipse will not edit it. Adding the library reference will succeed, but the change won't be persisted after hitting OK.
如果文件是只读的(签入源代码控制),eclipse就不会编辑它。添加库引用会成功,但是在点击OK后不会持久。
If closing the preferences window and reopening in again removes the library you just added, this may be your solution.
如果关闭preferences窗口并再次打开,删除刚才添加的库,这可能是您的解决方案。
#18
0
In case your library project still doesn't show up try adding library flag in your library project properties
如果您的库项目仍然没有显示,尝试在您的库项目属性中添加库标志。
Add android.library=true
添加android.library = true
project.properties
project.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
android.library=true
#1
159
OK Here is the solution which I found when I was looking for the default.properies file of the referencing project (not the library) in my file system. Although the referencing project was in the same eclipse workspace as the library project, the actual files were somewhere else in the file system ie they were'nt in the same parent folder of the library project. As soon as I placed the referencing project in the same physical folder as the library project it all went fine.
这是我在寻找默认值时找到的解。在我的文件系统中引用项目的属性文件(而不是库)。尽管引用项目位于与库项目相同的eclipse工作区中,但实际文件位于文件系统的其他地方,即它们不在库项目的相同父文件夹中。当我将引用项目放在与库项目相同的物理文件夹中时,一切都很顺利。
I guess that this must be something to do with android using ant underneath the covers.
我想这一定和android在幕后使用ant有关。
Edit: The project name needs match the folder name on the file system. What you are seeing in the Project Properties->Android->Library Reference is a relative file system path.
编辑:项目名称需要与文件系统上的文件夹名匹配。您在项目属性中看到的->Android->库引用是一个相对文件系统路径。
#2
11
Make Sure both the projects are present in same work space. To Do it, while importing the projects make sure "copy project into work space" check box is checked.
确保两个项目都存在于同一个工作空间中。要做到这一点,在导入项目时,要检查“复制项目到工作空间”复选框。
#3
10
the same problem will occur if your library project is in different partition from your current workspace. I have the same problem just now. My git source is in C: and I just move my workspace to D: and everything start to collapse.
如果您的库项目位于与当前工作区的不同分区中,则会出现相同的问题。我刚才遇到了同样的问题。我的git源代码是C:我把工作空间移动到D:一切都开始崩溃。
#4
4
Simplest way to get the library paths paths correct is to use the GUI from Eclipse to add the library as shown in the following screenshot and let Eclipse take care of putting the correct relative paths in project.properties. Its a common setup to have your library projects hosted at directories vastly different than your main projects that uses the library. This method will work if the "libary project" and the project using it are in the same eclipse "workspace" (they "need not" be in same parent folder):
获取库路径路径的最简单方法是使用Eclipse中的GUI来添加库,如下面的截图所示,让Eclipse负责在project.properties中放置正确的相对路径。这是一个常见的设置,使您的库项目驻留在与使用库的主要项目不同的目录中。如果“libary项目”和使用它的项目位于相同的eclipse“工作区”(它们“不需要”在相同的父文件夹中),则该方法将起作用。
#5
3
Please ensure that the library project is marked as "Is Library" - right click on the library project - properties - Android - mark the "Is Library" checkbox - in project.properties of the library project you should have a new entry:"android.library=true. Now add it into the project you want as described in the post below.(the post with image integrated - from Nilesh Pawar).
请确保图书馆项目被标记为“图书馆”-右击图书馆项目-属性- Android -标记“是图书馆”复选框-在项目中。库项目的属性应该有一个新条目:“android.library=true”。现在将其添加到您想要的项目中,如下所示。(由Nilesh Pawar提供图像集成的帖子)。
#6
3
This bug is referenced several times here 27199, 35786, 36460 & 38052
这个bug被多次引用在这里,27199,35786,36460和38052。
Maybe by voting for them, it will be fixed one day...
也许投票给他们,总有一天会修好……
#7
2
Yet another observation on the same issue.
另一个关于同样问题的观察。
For me the two projects where on the same parent folder, and were both local inside the workspace. Even then the issue was still happening.
对于我来说,这两个项目在同一个父文件夹中,并且都在工作区中。即便如此,这个问题仍在发生。
The I edited the "project.properties" file and put the absolute path(with forward slashes '/' for seperator) of the library project. Saved and closed it. Then went to the project properties dialog, removed the library(which was still showing the cross icon but with abs path) and added it back as usual. Surprisingly the issue is resolved, and the project compiles and runs.
我编辑了“项目”。属性“文件,并将该库项目的绝对路径(与前斜杠/“seperator”分隔开)。保存并关闭它。然后进入项目属性对话框,删除了库(它仍然显示交叉图标,但是带有abs路径),并像往常一样添加它。令人惊讶的是,这个问题已经解决了,并且项目编译并运行。
This is really strange and must be a bug with the ADT. I am using ADT version 20.0.2
这真的很奇怪,一定是ADT的bug。我使用的是ADT版本20.0.2。
#8
2
when developer referencing the facebook or any other library project then first of all clean the project from eclipse->project->clean project. that want allow the error of red cross in referencing screen.
当开发人员引用facebook或任何其他的库项目时,首先要清理eclipse->项目->clean项目中的项目。这就允许在引用屏幕上允许红色交叉的错误。
#9
2
For me, I just restart the eclipse and the added library works fine.
对我来说,我只是重新启动了eclipse,并且添加的库工作得很好。
I mean first time it showing red marks after adding the library project. Though eclipse main project and library project are in same workspace folder and no resources files are in outside of the project folder.
我的意思是第一次在添加了库项目后显示红色标记。尽管eclipse主项目和库项目位于相同的工作区文件夹中,并且没有资源文件在项目文件夹的外部。
So, you can try with to restart your eclipse. Happy coding....
因此,您可以尝试重新启动eclipse。快乐编码....
#10
1
Workaround for me was to
我的工作就是。
- Create a new workspace
- 创建一个新的工作区
- Import Library Project in that workspace
- 在该工作区中导入库项目。
- Import The desired project in that workspace
- 在该工作区中导入所需的项目。
- Having both project and library project the same target Android OS version
- 项目和库项目都有相同的目标Android OS版本。
- Reference library project in my project
- 在我的项目中参考图书馆项目。
solved my problem
解决了我的问题
#11
1
i had the same problem there when i try to change my workspace so this my solution:
当我试图改变工作空间时,我遇到了同样的问题,所以我的解决方案是:
- import and copy all project data including library project into workspace
- 导入和复制所有项目数据,包括库项目到工作区。
- delete the old project reference by Right-click on the project-->Properties-->Android-->Library, and select corrupted library(so that waht i call it) and choose Remove
- 删除旧的项目引用,右键单击项目——>属性——>Android——>库,并选择损坏的库(我称之为waht),然后选择Remove。
- clean project first (to refresh ur project properties)
- 清洁项目优先(刷新ur项目属性)
- go to library project Properties-->Android-->Library and check the is library if it does'nt click Apply then OK
- 转到库项目属性——>Android——>库,如果它不点击应用程序,就检查它的库。
- if the library project is library is already checked, first Unchecked it then Clean the library project after that do the Step 4 again
- 如果库项目已经被选中,首先检查它,然后在完成第4步之后清理库项目。
- go to project that u want the library are in then Right-click on the project-->Properties-->Android-->Library, Add then choose the library project (it should be there) and click Apply then OK
- 去到你想要图书馆的项目,然后右击项目——>属性——>Android——>库,然后选择库项目(它应该在那里),然后点击应用。
- if still doesn't appear clean the project once more time and that should do
- 如果仍然没有出现清理项目的时间和应该做的事情。
#12
1
Just restart your eclipse. It's solve my problem
只是重新启动eclipse。这是解决我的问题
#13
0
When you have a look at the reference-path before and after, it comes from i.e. "C:/workspace/mylib" and goes to "../../mylib" when copied to the correct location, quite interesting.
当你看一下之前和之后的参考路径,它来自于。"C:/workspace/mylib"然后去"../../mylib“当复制到正确的位置时,非常有趣。
#14
0
FYI,
通知你,
What worked for me was to delete the 'library' projects (the actual projects) from my workspace (without deleting the files), and then re-importing them using the wizard (import existing android project from source code).
我的工作是将“库”项目(实际项目)从我的工作空间中删除(不删除文件),然后使用向导重新导入它们(从源代码导入现有的android项目)。
#15
0
Thanks for posting the question. I had exactly the same problem while integrating Facebook with my Android application. I fixed the issue by moving my development project to the same Windows drive in which library project was located. Somehow Eclipse is unable to read the library project's location properly from default.properties file if it is in a different drive.
谢谢你提出这个问题。在整合Facebook和我的Android应用程序的同时,我也遇到了同样的问题。我将开发项目转移到与库项目相同的Windows驱动器上,从而解决了这个问题。某种程度上,Eclipse无法正确地从默认状态读取库项目的位置。属性文件,如果它在不同的驱动器。
#16
0
Similar to Sufi Khan's post I also solved this issue with a reboot. My case differed in that when I first accessed Properties->Android and added the library I got a lovely green checkmark. When I closed the dialog Eclipse was still showing class-not-found type errors. When I checked the properties again I saw the red X. But Mr. Kahn's solution (delete the bad lib, restart Eclipse, add the lib again) worked fine.
与Sufi Khan的帖子类似,我也通过重启来解决这个问题。当我第一次访问Properties->Android并添加了一个漂亮的绿色标记时,我的情况就不同了。当我关闭对话时,Eclipse仍然显示类未发现的类型错误。当我再次检查属性时,我看到了红色x,但是Kahn先生的解决方案(删除坏的lib,重新启动Eclipse,再添加lib)运行良好。
I'm using the 0702 version of the ADT bundle (starts with "cluster", rhymes with "duck").
我使用的是0702版本的ADT bundle(以“集群”开头,与“duck”押韵)。
#17
0
I followed the accepted answer but also had to make sure my "project.properties" file was readable.
我遵循了公认的答案,但也必须确保我的“项目”。属性文件是可读的。
If the file is readonly (checked into source control) eclipse will not edit it. Adding the library reference will succeed, but the change won't be persisted after hitting OK.
如果文件是只读的(签入源代码控制),eclipse就不会编辑它。添加库引用会成功,但是在点击OK后不会持久。
If closing the preferences window and reopening in again removes the library you just added, this may be your solution.
如果关闭preferences窗口并再次打开,删除刚才添加的库,这可能是您的解决方案。
#18
0
In case your library project still doesn't show up try adding library flag in your library project properties
如果您的库项目仍然没有显示,尝试在您的库项目属性中添加库标志。
Add android.library=true
添加android.library = true
project.properties
project.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
android.library=true