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): ...
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);
}
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
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.googlecode.com/hg/calendar-android-sample/
That code has exactly the same libs except:
- calendar lib is rev33 instead of rev41
- jackson and jackson-asl libraries are missing
- .properties file for each library file present in sample code but not in my 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;
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.
This post
java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker
says they were able to
import com.google.android.gms.common.AccountPicker;
But I'd like to know what library that came from.
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?
What am I doing wrong?
Thanks very very much for all your help.