2016-01-23 72 views
2

還有像這樣的問題,但它不是同一個錯誤。我相信我得到了我的依賴所有正確設置,但我不斷得到'Auth'無法解決的錯誤。無法解析符號'身份驗證'谷歌登錄集成

構建搖籃應用

apply plugin: 'com.android.application' 
apply plugin: 'com.google.gms.google-services' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.example.jophyjohnson.budgetme" 
     minSdkVersion 14 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.1.0' 
    compile 'com.android.support:design:23.1.0' 
    compile 'com.google.android.gms:play-services-cast:8.3.0' 
    compile 'com.connectsdk:connect-sdk-android:1.6.0' 


} 

建設搖籃工程

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:1.3.0' 

     classpath 'com.google.gms:google-services:1.5.0-beta2' 
     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

登入活動

package com.example.jophyjohnson.budgetme; 

import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 

import com.google.android.gms.auth.api.signin.GoogleSignInOptions; 
import com.google.android.gms.common.api.GoogleApiClient; 

/** 
* Created by Jophy Johnson on 1/23/2016. 
*/ 
public class SignInActivity extends AppCompatActivity { 
    // private GoogleApiClient mGoogleApiClient ; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) 
       .requestEmail() 
       .build(); 

     GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this) 
       .enableAutoManage(this /* FragmentActivity */, (GoogleApiClient.OnConnectionFailedListener) this /* OnConnectionFailedListener */) 
       .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
       .build(); 
    } 


} 

回答

14

添加

compile 'com.google.android.gms:play-services-auth:8.3.0' 

添加到您的gradle文件。

請注意,根據您的使用情況,您可能需要將8.3.0更改爲其他版本的播放服務。如7.5.09.6.110.0.0

0

您需要添加 compile 'com.google.android.gms:play-services-auth:8.3.0' 到依賴於應用級gradle這個塊。

+0

歡迎來到Stack Overflow!這並不能解答這個問題。要批評或要求作者澄清,在他們的帖子下留下評論 - 你總是可以評論你自己的帖子,一旦你[賺取](http://meta.stackoverflow.com/q/146472/169503)足夠[聲譽](http://stackoverflow.com/help/whats-reputation)你將能夠[評論任何職位](http://stackoverflow.com/help/privileges/comment)。如果你有一個相關但不同的問題,[請教一個新問題](http://stackoverflow.com/questions/ask)引用這個問題,如果它有助於提供上下文。 – Seth