Android Studio - GoogleAuthUtil无法解析

问题描述 投票:5回答:2

我正在使用Android Studio。

我需要使用Google帐户,但我收到了错误消息。

Cannot resolve symbol 'GoogleAuthUtil'

我已经进口了四个主要进口产品。

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有以下内容。

<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。

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

在尝试按照关于Eclipse的另一个问题中的步骤后,我尝试重新启动Android Studio:GoogleAuthUtil cannot be resolved

android android-studio google-play-services google-authentication
2个回答
4
投票

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

确保您已遵循documentation,确保已从SDK Manager安装了Extras/Google Repository并将以下依赖项添加到<project>/<modulename>/build.gradle文件(而不是root .gradle文件):

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

接下来,使用重建项目来同步项目和Gradle文件。


18
投票

您需要将play服务auth添加到build.gradle的依赖项中,如下所示:com.google.android.gms:play-services-auth:10.2.0

在这里查看更多:https://developers.google.com/android/guides/setup

© www.soinside.com 2019 - 2024. All rights reserved.