Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android import import com.google.android.gms.common.AccountPicker error

I am trying to implement an account picker with the following:

Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"}, false, null, null, null, null);

startActivityForResult(intent, 1111);

but I get error on import and in the android part of import com.google.android.gms.common.AccountPicker

How can I fix this?

in build Gradle I have

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.0.1'

}

is it the same as the article here?

Exception java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker

like image 628
Evridiki Avatar asked Feb 16 '26 14:02

Evridiki


1 Answers

You have missed the setup step that is adding GooglePlayService to your build.gradle.

In your build.gradle file inside your application module directory, add a new build rule under dependencies for the latest version of play-services:

compile 'com.google.android.gms:play-services:9.4.0'

If you only need AccountPicker:

1- you can replace above line with:

compile 'com.google.android.gms:play-services-base:9.4.0'

So you don't need to compile complete gms and you don't face 65,536 methods problem.

2- You don't need to add google play service for picking account. Use newChoosAccountIntent() method available in AccountManager class.

like image 62
Misagh Emamverdi Avatar answered Feb 19 '26 03:02

Misagh Emamverdi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!