Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GoogleApiClient cannot be resolved

I am working in Google App Indexing for my project.

Newbee for this feature. I just following the google guide lines.

Notify the google using API

In this page,asked to create an instance of GoogleApiClient. I tried but getting "GoogleApiClient cannot be resolved a type" error.

And I have added the following libraries into my project.

1.Google play services 2.Google api client 3.Google http api client

Installed Google APIs

and

Libraries included

the error is

Error image

How can I resolve this error?

like image 730
Karthikeyan Ve Avatar asked Jul 16 '14 07:07

Karthikeyan Ve


People also ask

What can I use instead of GoogleApiClient?

Nested Class Summary Use GoogleApi based APIs instead. See Moving Past GoogleApiClient. This interface is deprecated. use GoogleApi based APIs instead.

What is GoogleApiClient?

The GoogleApiClient.Builder class provides methods that allow you to specify the Google APIs you want to use and your desired OAuth 2.0 scopes. Here is a code example that creates a GoogleApiClient instance that connects with the Google Drive service: GoogleApiClient mGoogleApiClient = new GoogleApiClient.


2 Answers

  • Copy the library project at /extras/google/google_play_services/libproject/google-play-services_lib/ to the location where you maintain your Android app projects (your projects folder).
  • Import the library project into your Eclipse workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it (browse to the google-play-services_lib folder).
  • In your app project, reference Google Play services library project (right click on project, Properties, Android, click on Add..., select google-play-services_lib folder).
  • After you've added the Google Play services library as a dependency for your app project, open your app's manifest file and add the following tag as a child of the element (this is a new requirement as of updated Google Play Services):

    
    
    <meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" /> 
    

Then add this statement in your class (or fix the error):

import com.google.android.gms.common.api.GoogleApiClient


For Android Studio, follow directions here:

https://developers.google.com/android/guides/setup

like image 182
live-love Avatar answered Sep 22 '22 16:09

live-love


If you update SDK all...

  1. Remove "google-play-services.jar" in libs directory.
  2. Import google-play-services_lib project in SDK ([your-sdk]\extras\google\google_play_services\libproject\google-play-services_lib)
  3. Click your Project > Right Click > Properties > Click Android > Click [Add] button in the Library section and add google play library.
  4. And... Fix the Red alerts(?) :)

I hope this helps you...

like image 34
cmcromance Avatar answered Sep 20 '22 16:09

cmcromance