views:

142

answers:

1

I'm relatively new to Java, eclipse and android so this could be a completely silly question, but I'm going to ask it none the less.

I've got a project I'm learning with to test connecting to the flickr api and simply displaying recent images. I'm at the point now where I want to parse the JSON received from flickr. I've downloaded gson 1.4 and added the zip to the java build path through "add external jars." It's successfully loaded and I can see google-gson under referenced libraries in the package explorer. My problem is, when I try to use it, I simply get an error.

Gson gson = new Gson();

It highlights Gson and says that "Gson cannot be resolved to a type." What am I missing here? It worked once and has since stopped. I've tried removing the jars, cleaning the project and re-adding the jars but it still doesn't work.

Am I just completely noobing this up or is there another problem?

+1  A: 

I'm not sure exactly why this worked but I extracted the zip and just added gson-1-4.jar and it appears to have worked.

Hooray!

mattmcmanus
it could have been a bad jar OR it could be that you didnt import the class the first time, and eclipse did it automatically for you the second time (which it occasionally does).next time try pressing ctrl+shft+o, which automatically fills in any missing import statements. if the type exists in one of your libraries, it will get added. if its still missing... then its either the library or your spelling :p
mtmurdock
Thanks mtmurdock. I did however hit ctrl shitf o over and over. However it never added the appropriate imports when I did it. That is until I removed it and tried again.
mattmcmanus