GoogleAccountCredential选择帐户内容

时间:2012-12-18 09:13:53

标签: android google-api

我正在尝试启动一个有意图的选择帐户对话框,我通过了GoogleAccountCredential.newChooseAccountIntent

编译源代码时,发生错误NoClassDefFoundError

这是我的错误日志:

12-18 09:55:51.237: E/AndroidRuntime(25809): FATAL EXCEPTION: main
12-18 09:55:51.237: E/AndroidRuntime(25809): java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker
12-18 09:55:51.237: E/AndroidRuntime(25809):    at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.newChooseAccountIntent(GoogleAccountCredential.java:171)
12-18 09:55:51.237: E/AndroidRuntime(25809):    at com.arcticcoding.study.OverView.onCreate(OverView.java:67)
12-18 09:55:51.237: E/AndroidRuntime(25809):    at android.app.Activity.performCreate(Activity.java:4465)
12-18 09:55:51.237: E/AndroidRuntime(25809):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)

2 个答案:

答案 0 :(得分:0)

您需要参考Google Play服务库。我遇到过同样的问题 并在此处解决:

java.lang.NoClassDefFoundError on Android with GoogleAccountCredential.newChooseAccountIntent()

答案 1 :(得分:0)

build.gradle中,将此代码添加到依赖项:

compile('com.google.api-client:google-api-client-android:1.20.0') {
    exclude group: 'org.apache.httpcomponents'
}