Android Studio - 无法解析 GoogleAuthUtil [英] Android Studio - GoogleAuthUtil cannot be resolved

查看:30
本文介绍了Android Studio - 无法解析 GoogleAuthUtil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Android Studio.

I'm using Android Studio.

我需要使用 Google 帐户,但出现错误.

I need to use Google Accounts, but I'm getting an error.

Cannot resolve symbol 'GoogleAuthUtil'

我已经导入了四个主要的导入.

I've imported the four main imports.

import com.google.android.gms.auth.GoogleAuthException;
import com.google.android.gms.auth.GoogleAuthUtil;
import com.google.android.gms.auth.GooglePlayServicesAvailabilityException;
import com.google.android.gms.auth.UserRecoverableAuthException;

我是这么称呼它的.

final Account[] accounts = mAccountManager.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);

我的 AndroidManifest.xml 有以下内容.

My AndroidManifest.xml has the following.

<uses-sdk
    android:minSdkVersion="15"
    android:targetSdkVersion="18" />

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.NETWORK" />

我在开始我的项目时选择了 Android 4.3(修订版 18)Google API.

I selected Android 4.3 (Revision 18) Google APIs when starting my project.

我的 libs 文件夹中应该有 GooglePlayServices.jar 吗?如何在 Android Studio 中执行此操作?

Should I have the GooglePlayServices.jar in my libs folder? How do I do this in Android Studio?

在尝试按照有关 Eclipse 的另一个问题中的步骤操作后,我尝试重新启动 Android Studio:GoogleAuthUtil无法解决.

I've tried restarting Android Studio, after trying to follow steps in this other question about Eclipse: GoogleAuthUtil cannot be resolved.

推荐答案

然而,这是一些其他问题的重复:

This is a dup of a few other questions however:

确保您已遵循文档,确保您已从 SDK 管理器安装 Extras/Google Repository 并将以下依赖项添加到您的 //build.gradle 文件(不是 根 .gradle 文件):

Assure you have followed the documentation, make sure you have installed the Extras/Google Repository from the SDK Manager and added the following dependency to your <project>/<modulename>/build.gradle file (not the root .gradle file):

dependencies {
    compile 'com.google.android.gms:play-services-auth:16.0.+'
 }

接下来使用 同步您的项目和 Gradle 文件,然后重建您的项目.

Next sync your project and Gradle files using then rebuild your project.

这篇关于Android Studio - 无法解析 GoogleAuthUtil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆