如何将 Google Play Services 2 库安装修复到 Eclipse

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14142496/
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-09-10 21:29:47  来源:igfitidea点击:

How to fix Google Play Services 2 Library install to Eclipse

eclipsegoogle-play-services

提问by Hoopestr

I've tried to follow https://developer.android.com/google/play-services/setup.htmlinstructions in Eclipse for Mobile Developers (Juno), but am getting multiple errors with the library package after importing the library project into my workspace. I fixed the AndroidManifest.xml error it reported, but now I can't open the project in Eclipse saying the .project description file contains invalid information. So much for a simple install. I've tried uninstalling it, redownloading it, and I still get the multiple errors. Any suggesions how to get it working?

我尝试按照Eclipse for Mobile Developers (Juno) 中的https://developer.android.com/google/play-services/setup.html说明进行操作,但是在将库项目导入到我的工作区。我修复了它报告的 AndroidManifest.xml 错误,但现在我无法在 Eclipse 中打开项目,说 .project 描述文件包含无效信息。一个简单的安装就到此为止。我试过卸载它,重新下载它,但我仍然收到多个错误。任何建议如何让它工作?

回答by cdavidyoung

There is a misleading step in step 3 of http://developer.android.com/google/play-services/setup.html:

http://developer.android.com/google/play-services/setup.html 的第 3 步中有一个误导性步骤:

Copy the /extras/google/google_play_services/libproject/google-play-services_lib library project into the source tree where you maintain your Android app projects.

If you are using Eclipse, import the library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.

将 /extras/google/google_play_services/libproject/google-play-services_lib 库项目复制到您维护 Android 应用项目的源代码树中。

如果您使用的是 Eclipse,请将库项目导入您的工作区。单击 File > Import,选择 Android > Existing Android Code into Workspace,然后浏览到库项目的副本以将其导入。

Don't do the first copy. Instead just do the second part and check the box that says "Copy projects into workspace". I found that if I did the first part I would end up with empty xml files.

不要做第一个副本。相反,只需执行第二部分并选中“将项目复制到工作区”框。我发现如果我做了第一部分,我最终会得到空的 xml 文件。

回答by lokoko

Try the following :

尝试以下操作:

https://developers.google.com/maps/documentation/android/intro#sample_code

You would get errors while opening an activity mentioned in the sample code. That is because android.support.v4.app.FragmentActivity is not added to your build path. Hover over the error and click on "Fix Project Setup". It would ask you to add the lib to the build path. Say Yes and enjoy :)

打开示例代码中提到的活动时会出错。那是因为 android.support.v4.app.FragmentActivity 没有添加到您的构建路径中。将鼠标悬停在错误上,然后单击“修复项目设置”。它会要求您将 lib 添加到构建路径中。说是,享受 :)

回答by Ozan Atmar

If your google_pay_services/libproject is empty (mine was empty) and looks like installed in sdk manager, first delete google play services from sdk manager, install it again and follow the steps in the first answer.

如果您的 google_pay_services/libproject 为空(我的为空)并且看起来像是安装在 sdk 管理器中,请先从 sdk 管理器中删除 google play 服务,重新安装并按照第一个答案中的步骤操作。

回答by Thailand

Try Window > Android SDK Manager > Extras > Google play service > Delete package.

尝试Window > Android SDK Manager > Extras > Google play service > Delete package

And then re-install that package again:

然后再次重新安装该软件包:

File > Import,select Android > Existing Android Code into Workspace

File > Import,选择 Android > Existing Android Code into Workspace

回答by infantile

I had the same problem. I went to Properties->Java Build Path and clicked on the Projects tab. Then I added google-play-services_lib using the Add button. This got me this run-time exception:

我有同样的问题。我转到 Properties->Java Build Path 并单击 Projects 选项卡。然后我使用添加按钮添加了 google-play-services_lib。这给了我这个运行时异常:

E/AndroidRuntime(9469): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment

E/AndroidRuntime(9469):由:java.lang.ClassCastException:com.google.android.gms.maps.MapFragment 无法转换为 android.support.v4.app.Fragment

So then I changed the main.xml file entry from this:

然后我更改了 main.xml 文件条目:

      android:name="com.google.android.gms.maps.MapFragment"

to this:

对此:

    android:name="com.google.android.gms.maps.SupportMapFragment"

And FINALLY, it runs, but NOW no map due to authorization failure. So I am off on another search.

最后,它运行了,但由于授权失败,现在没有地图。所以我要开始另一次搜索了。

thanks Google for making it so complicated and for posting incorrect instructions!

感谢 Google 让它变得如此复杂并发布了不正确的说明!