问题描述
我是 androidstudio 的新手.我已经在 Eclipse 中集成了谷歌,但在工作室中遇到了问题.我正在从这个网站一步一步地跟随:https://developers.google.com/identity/sign-in/android/sign-in?configured=true
i am new in androidstudio. i have done integration of google in eclipse but am having issues in studio.i am following step by step from this site : https://developers.google.com/identity/sign-in/android/sign-in?configured=true
但是我遇到了问题.我收到一个错误,无法解析 API 所需的符号Auth",也无法解析SignInButton",请参阅代码:
but i am having an issue. i am getting an error that Cannot resolve symbol 'Auth' which i need for API and also cannot resolve 'SignInButton', see the code:
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
public class MainActivity extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener {
GoogleSignInOptions gso;
GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
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();
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
}
这是我的项目gradle:
this is my project gradle:
// 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
}
这是我的应用程序gradle:
this is my app gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.creaa.admin.googlesignin"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
apply plugin: 'com.google.gms.google-services'
}
请帮帮我.
推荐答案
将
apply plugin: 'com.google.gms.google-services'
放在apply plugin: 'com.android.application'
之下.在
dependencies
块中添加compile 'com.google.android.gms:play-services-auth:8.3.0'
.这会将相关的依赖项添加到您的项目中.Add
compile 'com.google.android.gms:play-services-auth:8.3.0'
insidedependencies
block. This will add related dependencies to your project.这篇关于无法在 android studio 中解析用于谷歌集成的符号“Auth"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!