Android Studio - GoogleAuthUtil cannot be resolved

I am using Android Studio.

I need to use Google accounts, but I get an error.

Cannot resolve symbol 'GoogleAuthUtil' 

I have imported four major 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; 

This is what I call him.

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

There are the following in my 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" /> 

I selected the Android 4.3 (version 18) Google API when starting my project.

Should I have GooglePlayServices.jar in my libs folder? How to do it in Android Studio?

I tried restarting Android Studio, trying to follow the steps in this other Eclipse question: GoogleAuthUtil could not be resolved .

+5
source share
2 answers

This is a duplication of some other issues, however:

Make sure you follow the documentation , make sure you install Extras/Google Repository from the SDK Manager and add the following dependency to your <project>/<modulename>/build.gradle (and not the root .gradle file):

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

Then sync your project and Gradle files using sync , then rebuild your project.

+3
source

You need to add play services authentication depending on build.gradle, for example: com.google.android.gms:play-services-auth:10.2.0

More details here: https://developers.google.com/android/guides/setup

+18
source

Source: https://habr.com/ru/post/1495847/


All Articles