简体   繁体   English

导入此参考android旁边显示红色X的google-play-service库

[英]Importing google-play-service library showing a red X next to this reference android

Am trying to add google-play-service library in my project using import(For Google map). 我正在尝试使用import(适用于Google地图)在我的项目中添加google-play-service库。 After adding the path am getting red X next to this reference and the reference is not adding . 添加路径后,此引用旁边的红色X变为红色,并且该引用未添加。 Know how to resolve this ? 知道如何解决吗?

The red X means its a broken link path. 红色的X表示链接路径断开。

http://developer.android.com/google/play-services/setup.html http://developer.android.com/google/play-services/setup.html

Copy the google-play services_lib library project to your workspace (folder where your android map project is). 将google-play services_lib库项目复制到您的工作区(您的Android地图项目所在的文件夹)。 The library project can be found under the following path. 可以在以下路径下找到该库项目。

     <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib library project .

Import the library project to your eclipse 将库项目导入到Eclipse

Click File > Import, select Android > Existing Android Code into Workspace, and browse the workspace import the library project . 单击文件>导入,选择Android>现有Android代码到工作区,然后浏览工作区导入库项目 You can check if it is library project. 您可以检查它是否是图书馆项目。 Right click on the library project. 右键单击库项目。 Goto properties. 转到属性。 Click Android on the left panel. 点击左侧面板上的Android。 You will see Is Library checked. 您将看到是否选中了库。

Right click on your android project. 右键单击您的android项目。 Goto properties. 转到属性。 Choose Android on the left panel. 在左侧面板上选择Android。 Click on Add and browse the library project. 单击添加并浏览库项目。 Select the same. 选择相同。 Click ok and apply 单击确定并应用

在此处输入图片说明

Eclipse does weird things when importing an existing project (google-play-services-lib), especially if you try to import and then allow the project to be automatically 'copied' to your workspace. 在导入现有项目(google-play-services-lib)时,Eclipse会做一些奇怪的事情,尤其是当您尝试导入然后允许该项目自动“复制”到您的工作区时。 I had the same issue and here is how I fixed it: 我遇到了同样的问题,这是我如何解决的问题:

  • Close Eclipse 关闭Eclipse

  • Erase all google-play-services projects from your workspace 从您的工作区中删除所有的Google Play服务项目

  • Manually copy the google-play-services-lib folder (....sdk\\extras\\google\\google_play_services\\libproject\\google-play-services_lib) into your workspace 手动将google-play-services-lib文件夹(.... sdk \\ extras \\ google \\ google_play_services \\ libproject \\ google-play-services_lib)复制到您的工作区中

  • Open Eclipse 打开Eclipse

  • Add a new project, choosing 'Existing Android Project', then navigate to your workspace and add the newly copied google-play-services-lib project 添加一个新项目,选择“现有Android项目”,然后导航到您的工作区并添加新复制的google-play-services-lib项目

  • Finally, add the google-play-services-lib to your project as a library (just like you normally would) 最后,将google-play-services-lib作为库添加到您的项目中(就像通常一样)

Hope this helps! 希望这可以帮助! :) :)

Though it's over a year for this question but never the less thought of putting it down here. 尽管这个问题已经过去了一年,但从来没有想到过将它放在这里。 Might help some one facing a similar issue. 可能会帮助一些面临类似问题的人。

While doing a File -> Import one probably might have selected the folder, 在执行File -> Import可能已经选择了该文件夹,

C:\adt-bundle-windows-x86-20130729\sdk\extras\google\google_play_services\ 

instead of 代替

C:\adt-bundle-windows-x86-20130729\sdk\extras\google\google_play_services\libproject\google-play-services_lib

Quite strange as Eclipse did not correctly copy the google-play-services_lib project in my workspace, but this caused a cross mark to appear in my Project Properties. 很奇怪,因为Eclipse无法在我的工作区中正确复制google-play-services_lib项目,但是这导致一个十字标记出现在我的项目属性中。

got a perfect solution for your question. 为您的问题提供了完美的解决方案。 this problem is due to improper referencing of library projects. 此问题是由于对图书馆项目的引用不正确造成的。 You need follow these step. 您需要按照以下步骤。

  1. create a new project 创建一个新项目
  2. copy all the java files from src of your previous project in which you are getting error to the new project you have created just now. 将您遇到错误的上一个项目的src中的所有java文件复制到您刚刚创建的新项目中。
  3. Also copy layouts xml files. 还复制布局xml文件。
  4. now import play services you will not get this error. 现在导入播放服务,您将不会收到此错误。

I was also getting same problem. 我也遇到了同样的问题。

I copied google library folder into work space and import now it's working fine. 我将google library文件夹复制到工作区并导入,现在一切正常。

尝试通过单击文件>导入,选择Android>现有Android代码到工作空间中,处理文件,将Google Play服务库与您的工作目录放置在同一工作目录中,然后浏览工作空间以导入库项目。

You add Project in to your workspace. 您将Project添加到您的工作区。 Start Eclipse and import project one option is ther copy to workspace do it. 启动Eclipse并导入项目,一种选择是将其复制到工作区。 After that add google play services it also copy in to your work space and add it your library hope so its working. 添加Google Play服务之后,它还会复制到您的工作区中,并将其添加到您的书架中,以使其正常工作。

这是常见的问题Youur google-play-service-lib项目和你的android project应该是内部的same folder例如,如果你的Android应用项目的名字是MyMap是在D:/workspace牛逼母鸡您的play service lib projec T应当在同一目录D:/workspace

Close Eclipse. 关闭Eclipse。 Delete 删除

.metadata .metadata

and

.recommaditions 。推荐

folders from your workplace. 工作场所中的文件夹。 Import your projects back. 导入您的项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM