java.lang.NoClassDefFoundError的在Android与GoogleAccountCredential.newChooseAccountIntent() [英] java.lang.NoClassDefFoundError on Android with GoogleAccountCredential.newChooseAccountIntent()

查看:464
本文介绍了java.lang.NoClassDefFoundError的在Android与GoogleAccountCredential.newChooseAccountIntent()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发针对Android 4+与Eclipse ADT朱诺包+谷歌Eclipse插件。 我需要以编程方式登录到谷歌帐户使用的谷歌日历API。对于 这个我利用客户经理。我得到以下错误:

I am developing for Android 4+ with Eclipse Juno ADT bundle + Google Plugin for Eclipse. I need to programmatically log into a google account to use the Google Calendar API. For this I am making use of account manager. I get the following error:

05-05 13:28:55.605: E/AndroidRuntime(11186): FATAL EXCEPTION: main
05-05 13:28:55.605: E/AndroidRuntime(11186): java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker
05-05 13:28:55.605: E/AndroidRuntime(11186):    at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.newChooseAccountIntent(GoogleAccountCredential.java:171)
05-05 13:28:55.605: E/AndroidRuntime(11186): ...

下面是code,导致它:

Here is the code that causes it:

GoogleAccountCredential credential;

credential = GoogleAccountCredential.usingOAuth2(this, CalendarScopes.CALENDAR);

chooseAccount();

private void chooseAccount() {

  startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);

}

我寻觅计算器解决方案。该库目录包含日历 Eclipse的库文件,我通过谷歌插件进口的Eclipse(里面还放 有认证等等库):

I have searched stackoverflow for solutions. The libs directory contains the calendar library files for eclipse I imported via google plugin for eclipse (which also put there the authentication etc... libraries):

android-support-v4.jar
google-api-client-1.14.1-beta.jar
google-api-client-android-1.14.1-beta.jar
google-api-services-calendar-v3-rev41-1.14.2-beta.jar
google-http-client-1.14.1-beta.jar
google-http-client-android-1.14.1-beta.jar
google-http-client-gson-1.14.1-beta.jar
google-http-client-jackson-1.14.1-beta.jar
google-http-client-jackson2-1.14.1-beta.jar
google-oauth-client-1.14.1-beta.jar
gson-2.1.jar
jackson-core-2.1.3.jar
jackson-core-asl-1.9.11.jar
jsr305-1.3.9.jar

然而这些似乎并没有包含

These however do not seem to include

com.google.android.gms.common.AccountPicker

如果我输入这在我的$ C C的code导入行$被标记为错误。 那么这是什么一回事。我已经从谷歌日历样本复制此code的地方 运行得很好:

If I import this in my code the import line of code is flagged as an error. So what's up. I've copied this code from the Google Calendar Sample where it runs just fine:

http://samples.google-api-java-client.google$c$c.com/hg/calendar-android-sample/

这code具有完全相同的库除外:

That code has exactly the same libs except:

  1. 在日历LIB是rev33而不是rev​​41
  2. 杰克逊和杰克逊ASL库丢失
  3. 的.properties文件中为每个库文件present样品code,但不是在我的code

所以这应该不是问题。然而, 在寻找的code中的进口部分中,谷歌日历样本code的:

So this should not be the problem. However, looking in the imports section of the code, the google calendar sample code has:

import com.google.android.gms.common.GooglePlayServicesUtil;

但如果我尝试插入该行的code在我的code就被标记为错误 话说进口com.google.android.gms.common.GooglePlayServicesUtil 解决不了。

but if I try to insert this line of code in my code it is tagged as an error saying the import com.google.android.gms.common.GooglePlayServicesUtil cannot be resolved.

这个帖子

<一个href="http://stackoverflow.com/questions/14790149/java-lang-noclassdeffounderror-com-google-android-gms-common-accountpicker">java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker

说,他们能够

import com.google.android.gms.common.AccountPicker;

不过,我想知道是什么库,是从哪里来的。

But I'd like to know what library that came from.

我甚至尝试寻找原生Android日历样本 库从中我可以包括com.google.android.gms.common。* 通过检查一个文件的时间,但无法找到它。怎么样 这可能吗?

I even tried looking in the original android calendar sample for the library from which I can include com.google.android.gms.common.* by inspecting one file at a time but could not find it. How is it possible?

我是什么做错了吗?

感谢非常非常的所有帮助。

Thanks very very much for all your help.

推荐答案

好了,我发现我失踪了。

OK, I've found out what I was missing.

  1. 确保你已经下载了Android SDK服务 - >附加功能 - >谷歌Play业务

  1. Ensure you have downloaded the Android SDK Services -> Extras -> Google Play services

请通过下面的链接提供的说明 对谷歌播放-服务-LIB库添加到您的项目:

Follow the instructions provided by the following link to add the google-play-services-lib library to your project:

http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject

最好的问候

这篇关于java.lang.NoClassDefFoundError的在Android与GoogleAccountCredential.newChooseAccountIntent()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆