0

While trying the google plus API example from the project site I'm completely stuck with one import:

import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;

This thing just doesn't seem to exist in the project.

The sample is a read-made Eclipse project I imported, and to be sure I checked if the massive amount of .jar's in the /lib directory are added to the build path. They are, I can see them listed in the Referenced Libraries part in my Eclipse project.

I can find mentions of com.google.api.client.googleapis.extensions.android2.auth but there just doesn't seem to be any GoogleAccountManager class around.

Several possibilities I have come up with, but can't find out which is it, let alone find a solution to them:

  • I have not set up my project correctly. I doubt it, but completely possible. This would mean that the example has a broken project set-up and/or I managed to not import all libraries?
  • The class or package or something like that is renamed // named differently. This would mean the example is broken out of the box, and that I still need to find the correct class (and change the import + calling code to that)
  • Something else :D

The following are the contents of the libs directory as you can also browse on the project page . Notice that it does containt google-http-client-extensions-android2-1.6.0-beta.jar

google-api-client-1.6.0-beta-sources.jar
google-api-client-1.6.0-beta.jar
google-api-client-extensions-1.6.0-beta-sources.jar
google-api-client-extensions-1.6.0-beta.jar
google-api-client-extensions-android2-1.6.0-beta-sources.jar
google-api-client-extensions-android2-1.6.0-beta.jar
google-api-services-plus-v1-1.3.0-beta-sources.jar
google-api-services-plus-v1-1.3.0-beta.jar
google-http-client-1.6.0-beta-sources.jar
google-http-client-1.6.0-beta.jar
google-http-client-extensions-1.6.0-beta-sources.jar
google-http-client-extensions-1.6.0-beta.jar
google-http-client-extensions-android2-1.6.0-beta-sources.jar
google-http-client-extensions-android2-1.6.0-beta.jar
google-http-client-extensions-android3-1.6.0-beta-sources.jar
google-http-client-extensions-android3-1.6.0-beta.jar
google-oauth-client-1.6.0-beta-sources.jar
google-oauth-client-1.6.0-beta.jar
gson-1.7.1.jar
guava-r09.jar
Nanne
  • 64,065
  • 16
  • 119
  • 163
  • http://code.google.com/p/google-api-java-client/source/browse/google-api-client-googleapis-extensions-android2/src/main/java/com/google/api/client/googleapis/extensions/android2/auth/GoogleAccountManager.java?r=293c6f883b157d50adb0fbcefcf1bbfc1bac583f – Peter Knego Jan 08 '12 at 11:26
  • Yes. that is the source. But I can hardly just make a new java file and copy past that, can I? :D. There is a jar "google-api-client-1.6.0-beta.jar" which I suspect is the equivalent of that link, so should contain that class. It is in my build path, but the class isn't there as far as eclipse is conserned. What do you suggest I do? Add a second api-client lib to the project? – Nanne Jan 08 '12 at 11:32

2 Answers2

2

On the first page is a link to updated Google plus libraries google-plus-java-starter_v5.zip

Updated Link: google-plus-java-starter_v5.zip

It contains android/libs/google-api-client-extensions-android2-1.6.0-beta.jar, which contains GoogleAccountManager class.

As this is an extension it probably needs other jars too.

(summary of comments) Manually adding /libs/google-api-client-extensions-android2-1.6.0-beta.jar to the build path and verifying that it is in the Referenced Libraries fixes the problem. It is unknown (to me (Nanne)) why this doesn't happen automagically when adding the libraries, but there you are.

Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • I've added the allready imported contents of the lib directory, which you can also check out here: http://code.google.com/p/google-plus-java-starter/source/browse/#hg%2Fandroid%2Flibs . I believe the file is allready there. – Nanne Jan 08 '12 at 11:38
  • The class is definitely in the jar. Check with eclipse why it is not including it. – Peter Knego Jan 08 '12 at 11:42
  • That's what I'm trying to figure out here :). It is in my build path, it is in my referenced libraries, but all I can see for that file is a "AndroidHttp.class" – Nanne Jan 08 '12 at 11:55
  • If I go to [the file in the example](http://code.google.com/p/google-plus-java-starter/source/browse/android/libs/google-http-client-extensions-1.6.0-beta.jar) and download it, I don't see that class. Would that mean the sample is broken, and contains an incomplete jar file? – Nanne Jan 08 '12 at 11:58
  • Because it's not in that jar. It's in android/libs/google-api-client-extensions-android2-1.6.0-beta.jar – Peter Knego Jan 08 '12 at 12:13
  • You're absolutely right, I clicked to the wrong place :). but that still doesn't explain why I can't use it. – Nanne Jan 08 '12 at 12:21
  • It seems that the alike-looking names just add some confusion, and the basic problim is that the file doesn't get added to the build path. Can't seem to figure out why, but redownloading the project etc doesn't help. If I manually add that file to the build path in a new download it does get added. Again, I'm not really sure why, but it works in the end. I'll accept your answer and add my summary of these comments if you don't mind :) – Nanne Jan 08 '12 at 12:31
  • Though this seems to have helped as far as "finding" the classes, the final project freezes (FC), presumably because there is still something wrong with the builp path/depencys. It mentions: " _java.lang.NoClassDefFoundError: com.google.api.client.http.javanet.NetHttpTransport_ ". I can find the line that produces it, and find the source (`NetHttpTransport`) it refers to in my project, but it still crashes. It is this problem: http://stackoverflow.com/questions/7648039/android-and-google-client-api-nethttptransport-class-not-found . I'll check the libs, but I can find the class allready :( – Nanne Jan 08 '12 at 13:45
1

Right-click on Project, select Properties->Java Build Path->Order and Export Tab->click on checkbox for “Android Private Libraries”. That worked for me.