Reputation: 505
I getting a few issues with the Google Play Service Libraries.
I have imported these files:
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
I am getting errors throughout the project for "GoogleApiClient":-
public class MainActivity extends FragmentActivity implements LocationListener,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener
Here I get errors with locationClient/ LocationServices/ GoogleApiClient
locationClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
Here is get errors for "locationClient"
@Override
public void onStop() {
// If the client is connected
if (locationClient.isConnected()) {
stopPeriodicUpdates();
}
// After disconnect() is called, the client is considered "dead".
locationClient.disconnect();
super.onStop();
}
/*
* Called when the Activity is restarted, even before it becomes visible.
*/
@Override
public void onStart() {
super.onStart();
// Connect to the location services client
locationClient.connect();
}
Here I get error for "onConnectionSuspended"
@Override
public void onConnectionSuspended(int i) {
Log.i(Application.APPTAG, "GoogleApiClient connection has been suspend");
}
Upvotes: 2
Views: 2484
Reputation: 43322
Make sure that you have included Google Play Services in your build.gradle dependencies, for example:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
}
Upvotes: 2