简体   繁体   中英

Google place API integration

I'm using sample code for google place api from GitHub

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

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). 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). And then it will run as a Android Project.

Else refer this Tutorial Introducing the Google Places API with nice explanation.

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.

Download the Google Api Java Client

Create a libs folder in your eclipse project.

Drag and drop all client files that do not end in -source into the libs folder you just made. Do not add the dependencies folder, instead drag the dependencies from inside the folder to the libs folder.

Go to Project -> Properties -> Java Build Path -> Libraries Tab

Click Add JARS, navigate to your libs folder and add all of the client files.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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