简体   繁体   English

Google Place API整合

[英]Google place API integration

I'm using sample code for google place api from GitHub 我正在使用来自GitHub的 Google Place API的示例代码

And, having following error while am using above Example - 而且,在使用上述示例时出现以下错误-

 Could not find class 'com.google.api.client.http.apache.ApacheHttpTransport', referenced from method hung.vo.PlaceRequest.<clinit> Could not find class 'hung.vo.PlaceRequest$1', referenced from method hung.vo.PlaceRequest.createRequestFactory Could not find class 'com.google.api.client.http.GenericUrl', referenced from method hung.vo.PlaceRequest.performSearch Caused by: java.lang.VerifyError: hung.vo.PlaceRequest hung.vo.hung.vo.GooglePlaceActivity$SearchSrv.doInBackground(GooglePlaceActivity.java:36) 

and in GooglePlaceActivity line 36 is GooglePlaceActivity中,第36行

pl = new PlaceRequest().performSearch();

Actually, The Project which you are referring its a Maven Project , so you can't add it as a simple Android Project in your Eclipse Workspace (I hope you are using Eclipse). 实际上,您要引用的Project是一个Maven Project ,因此您不能将其作为简单的Android Project添加到Eclipse Workspace中(我希望您使用的是Eclipse)。 For this you have to use Eclipse - Maven Plugin in your Eclipse and import this project as a import Existing Maven Project .. When you build this Project as a Maven Build then It will automatically resolved all dependencies jar file by including them (You don't have to add manually it). 为此,您必须在Eclipse中使用Eclipse-Maven插件并将该项目作为导入的现有Maven项目导入 。.当您将该项目构建为Maven Build时 ,它将通过包含它们自动解决所有依赖项jar文件(您不这样做)。不必手动添加)。 And then it will run as a Android Project. 然后它将作为Android项目运行。

Else refer this Tutorial Introducing the Google Places API with nice explanation. 否则,请参考本教程介绍Google Places API,并提供详细说明。

Also You can only use source of above project and add Manually Google APIs Client Library for Java to your android project's build path without using as a Maven Project. 另外,您只能使用上述项目的源代码,并手动将Java的Google API客户端库添加到您的android项目的构建路径,而不能用作Maven项目。

Download the Google Api Java Client 下载Google Api Java客户端

Create a libs folder in your eclipse project. 在eclipse项目中创建一个libs文件夹。

Drag and drop all client files that do not end in -source into the libs folder you just made. 将所有不以-source结尾的客户端文件拖放到您刚创建的libs文件夹中。 Do not add the dependencies folder, instead drag the dependencies from inside the folder to the libs folder. 不要添加依赖项文件夹,而是将依赖项从文件夹内部拖动到libs文件夹。

Go to Project -> Properties -> Java Build Path -> Libraries Tab 转到项目->属性-> Java构建路径->库选项卡

Click Add JARS, navigate to your libs folder and add all of the client files. 单击添加JARS,导航到您的libs文件夹并添加所有客户端文件。

Click the Order and Export tab and check off all the client files you added. 单击“订购和导出”选项卡,然后选中所有添加的客户端文件。

Clean the project. 清理项目。 You should be good to go. 你应该很好。

See this Link it's the same problem as yours. 看到此链接,这与您的问题相同。

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

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