Android的工作室 - GoogleAuthUtil不能得到解决工作室、Android、GoogleAuthUtil

2023-09-07 03:18:25 作者:举杯畅饮诉情衷

我使用Android的工作室。

I'm using Android Studio.

我需要使用谷歌帐户,但我得到一个错误。

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;

下面是我如何我打电话吧。

Here's how I'm calling it.

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

我的Andr​​oidManifest.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)谷歌API的开始我的项目时。

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

我应该有GooglePlayServices.jar在我的libs文件夹?我该怎么做这个Android Studio中?

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

我试图重新启动Android的工作室,试图按照有关Eclipse这个问题的其他步骤后: GoogleAuthUtil解决不了。

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

推荐答案

这是几个其他问题一个DUP但是:

This is a dup of a few other questions however:

向你保证已经按照文档,确保你已经安装了其他/谷歌库从SDK管理器并添加以下依赖你的&LT;项目&GT; /&LT; MODULENAME&GT; /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:3.1.+'
 }

下次同步您的项目,并使用摇篮文件然后重新构建项目。

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