I am developing an AppEngine application where I gotta work with Google Calendar API. Because of some reasons, we are not using the lastest version of this API (v3) and we are working with gdata-calendar-v2 which is still working until the next November.
All right, I have two methods where I am using the Calendar Service. For one hand, I am adding a new event on my calendar and I do something like:
CalendarService myService = new CalendarService("my_calendar"); // error on this line
myService.setUserCredentials(EMAIL, PASSWORD);
As I know, it is working fine and I am adding new events on my calendar with no problems.
For another hand, I have another method where I do something different but I am using the same snippet code to connect to Google Calendar. In this case, I get this error:
Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;
at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableTypes(AltFormat.java:399)
at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableXmlTypes(AltFormat.java:387)
at com.google.gdata.wireformats.AltFormat.<clinit>(AltFormat.java:49)
at com.google.gdata.client.Service.<clinit>(Service.java:558)
The libraries that I am using with -collections- and you can be interested are:
Guava 11 (I already update to 18 and it's the same problem).
I know there is a very similar thread with the same problem right here but there is one difference: it is working fine in one method of my project and it is not working fine in another.
Can you give me a helping hand?
Thank you in advance,
Diego.
Solution:
I have been searching in Google and I found out this thread
I have changed my Guava to guava-10.0.1.jar and I don't get this error anymore.
The latest version of the gdata client library for java (version 1.46.0 as of this writing, found here: https://code.google.com/p/gdata-java-client/downloads/list) still embeds google-collections-1.0-rc1.jar inside their dependencies, and at this point it's not able to be replaced by the latest guava version.
Most likely you're using two different version of Guava. Add the line
System.out.println(ImmutableSet.class.getClass().getResource("/"));
to the line before the exception to find out where the conflicting version resides.
Current Guava has the method
public static <E> ImmutableSet<E> copyOf(E[] elements) {}
Some older version (e.g., Google collections) do not. It looks like
com.google.gdata.wireformats.AltFormat$Builder
accesses the old version.
Related
Followed instructions in here https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-java-how-to-use-queues to test a java application to connect, send and recieve the messages
With version of 7.0.2 for azure-messaging-servicebus, all is working okay.
However when I update the version, getting errors either at build time or at run time.
I know it should be backward compatible and guess I am doing something wrong. I tried updating the verion of azure-core as well but no luck. Appreciate if someone could help.
7.3.0 -- java.lang.ClassNotFoundException: com.azure.core.util.AsyncCloseable
7.7.0 -- java.lang.ClassNotFoundException: com.azure.core.client.traits.TokenCredentialTrait
The 'java.lang.ClassNotFoundException' is a Java checked exception that happens when the JVM tries to load a class but cannot locate it in the classpath.
Generally, because the 'ClassNotFoundException' is a checked exception, it must be explicitly handled in methods that can throw it - either via the use of a 'try-catch block' or through the use of the 'throws' clause.
You can refer this similar SO threads for more information.
Reference1 , Reference2
I have been trying for the past day to get at least google's sample code working. Every single of their sample code have dependencies issues or errors within the code (even they have stated in quick start thats a copy/pasta code to test the api - never works). I have installed all of the dependencies, I pointed the jar file to the missing imports, but no success in that..
Can anyone tell me where is the problem when my jar is in dependencies but it never finds it?
I wish they had a normal way of taking json data - via url, but they disabled this.
My goal is setting the URL for the profile picture of an existing user.
I'm using the Google Identity Toolkit Java library on App Engine.
Below is my code:
GitkitUser u = gitkitClient.getUserByLocalId(localId);
u.setPhotoUrl(profilePictureURL);
gitkitClient.updateUser(u);
where gitkitClient' is my GitKit client, already initialized with the right parameters, andlocalId' is the id of the user I'd like to update.
This code causes the following exception:
org.json.JSONException: JSONObject["localId"] not found.
Documentation is hard to find for this library. I'd be glad if someone could suggest me what I'm missing there.
Thanks for reporting the bug. It will be fixed in one or two days.
[UPDATE] It's fixed. I manually tested and verified. Please also use the newest version of java library. You can get it from here or from maven update.
I've been trying to get a basic project from the samples from Google running for a few hours now. I've followed every step so far and not really changed anything from what it's told me but after importing all the libraries and pasting the default code the program is complaining.
Description Resource Path Location Type
AccessTokenResponse cannot be resolved to a type MainActivity.java line 63 Java Problem
Some others are reported missing like. GoogleAccessProtectedResource, GoogleAuthorizationCodeGrant, GoogleAuthorizationRequestUrl.
From the default code of
// Step 1: Authorize -->
String authorizationUrl = new GoogleAuthorizationRequestUrl(clientId, redirectUrl, scope)
.build();
The fact this is not working is obviously leading to assume it's something to do with oauth2.
I'm pretty new to fiddling around with Android and Java, but after reading around I did manually import the libraries via right clicking > properties > java build path.
I've imported all the ones it said to import and cannot understand why it is erroring on practically the first step.
This is what I've imported.
Libraries:
All I want to do is view a public calendar in the Android Application. Been so much bother to get this API working
The code that I'm looking at for setting this up is found here
Thanks!
Hi I am facing the same issue with other classes of the client library, particularly with the GoogleAccessProtectedResource class.
From what I found out GoogleAuthorizationRequestUrl is not being used any more in the latest versions instead of that you should try to use GoogleAuthorizationCodeRequestUrl which is found in the following package
com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl;
I've been having tremendous problems with connecting my android app to the youtube API. Firstly I tried to go along the route of using the native youtube gdata java client(http://code.google.com/p/gdata-java-client/). I had read that this could then be integrated into an android app easily enough and so I set about doing that but I would stumble every time at the line
YouTubeService ytservice = new YouTubeService("AppName",Dev_Key);
I'd enter the correct details here, even have all the necessary external jars but every time I would be given a NoClassDefFoundError reporting that YouTubeService could not be found and neither could it's superclass, MediaService. (Just so you know, I had gdata-youtube-2.0.jar, gdata-client-1.0.jar, gdata-media-1.0.jar, guava.11.0.2.jar and jsr305.jar)
So then I tried which appeared to support android (http://code.google.com/p/google-api-java-client/wiki/Android). There was even a sample example where google tasks had been integrated so it looked promising. It didn't have an actual YouTube class like it did have a taskService but it did support OAuth 2.0 login which I could work with by just sending off URL requests to the youtube API with OAuth 2.0 authentication. I tried this but when the only key I could get from it in combination with android's AccountManager was an auth key token. Posting this with the URL request to google resulted in an 'authentication required' response from youtube(because i was providing an incorrect access token, it was at least twice the size of a working access token i was comparing it with).
How can I find the access token that I need for the youtube API from the AccountManager? Or even better, how can I get the YouTubeservice to work?
Thanks
rory
Edit
Amad, thanks for the answer but unfortunately that is what i am already doing:
(source: themobilelook.com)
maybe it'll help if i supply my project folder: here it's a barebones setup, literally just to test if the YouTubeService works.
using adt 20, jdk compliance level 1.6
if you manage to create a working version then itnwoild be great if you could share it
The YouTube API library/libraries must be included in the project. By going to the Project Properties > Build Path > Order and Export tab, you can tick the checkbox next to the all YouTube-API-related libraries to ensure that they will be included in the project when you export it. Make sure to clean and rebuild after doing this.
As for the access token... not totally sure. The documentation may help there. This Google Groups thread may help also.
If you get NoClassDefFoundError during Runtime, then I suspect you did not include them to work at runtime. You have to check the checkbox for each .jar like this:
(Of course you have to add them to your java build path first)