问题
I want to make a login with Google+ login button like this Tutorial
I have copied the codes, set google_play_services libraries, added package name and SHA1 key in google api console, but there are some import errors :
This import is not an error :
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.plus.model.people.Person;
But this import an error (cannot be resolved) :
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.plus.Plus;
Anybody have a solution ?
回答1:
Add this in yourbuild.gradle
(app) inside dependency
compile 'com.google.android.gms:play-services:8.1.0'
回答2:
[Solved]
I try to download new version of google-play-services library and import error is gone.
So, always update/download newest version of google-play-services library..
回答3:
You need to add the dependency to your app. Instructions for eclipse here http://developer.android.com/google/play-services/setup.html
You can also do this by right clicking on your app (if you're using Android Studio) selecting Open Module Settings, going to the dependency tab. Then Clicking the "plus" at the lower left, select library dependency, then find play-services
来源:https://stackoverflow.com/questions/28262213/import-com-google-android-gms-common-api-googleapiclient-cannot-be-resolved