我正在使用AndroidStudio编写应用程序,我想将其与Google+登录集成,因此我使用了教程。
在我的LoginActivity上是这段代码:
protected void onCreate(Bundle savedInstanceState) {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
(...)
在build gradle上我有:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
(...)
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'
然而,在LoginActivity我得到“无法解析符号mGoogleApiClient。 我怎样才能解决这个问题?
答案 0 :(得分:8)
你必须在onCreate()
之前声明它GoogleApiClient mGoogleApiClient;