4

I am getting this compile error.I had added the google play services lib in same workspace.Then added the latest sdk(tools,extras) successfully.

But I didn't know why this error still occurs.

import com.google.android.gms.location.LocationClient;  -->import cannot be resolved


public class Main extends Activity implements
        GooglePlayServicesClient.ConnectionCallbacks,
        GooglePlayServicesClient.OnConnectionFailedListener {

private LocationClient mLocationClient;   --->LocationClient cannot be resolved to a type


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    mLocationClient = new LocationClient(this, this, this);

}
}

In Console:

I am getting this, No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').

Manifest:

 <uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="21" />

   <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

........
</application>

Edit:

enter image description here

enter image description here

Anybody can help me with this.Thanking you.

Stephen
  • 9,899
  • 16
  • 90
  • 137

2 Answers2

6

Update: The docs seem to be updated now.

I had the same problem about a week ago the problem is because the GooglePlayServices library is updated and also the LocationClient was deprecated as well (but the docs were not updated). You must have updated the GooglePlayServices library and then this error occurred.

So instead of using the old LocationClient you need to use com.google.android.gms.common.api.GoogleApiClient and com.google.android.gms.location.LocationRequest.

See the docs for GoogleApiClient and LocationRequest

Community
  • 1
  • 1
SMR
  • 6,628
  • 2
  • 35
  • 56
  • I am added that two imports.but still error occurred. – Stephen Jan 19 '15 at 04:58
  • 1
    see http://stackoverflow.com/questions/24611977/android-locationclient-class-is-deprecated-but-used-in-documentation to resolve this and make sure you have updated the **Google Play Services library** and **Google Repository**. and also dont forget to import the updated library in your project. – SMR Jan 19 '15 at 05:00
  • 1
    Note: all the docs are indeed updated at this time :) – ianhanniballake Jan 19 '15 at 05:20
0

This is because LocationClient is deprecated for new Google Play Services. And i think you have already used a latest google play service. So you just change your LocationClient with GoogleApiClient which is replaced with LocationClient for new latest Google play services which will solve your issue.

Further more you can visit this Link

Piyush
  • 18,895
  • 5
  • 32
  • 63