0

I am using last.fm API from here http://code.google.com/p/lastfm-java/

I downloaded it to my workspace, checked it as library, and imported it to my project... The problem comes when I try to use one method of the API

Artist[] artist = LastFmServer.searchForArtist("hatebreed"); 

I dont know why, it says

Cannot make a static reference to the non-static method searchForArtist(String) from the type LastFmServer 

But I have another error trying to solve it. It causes this line

String artist = Artist.getName(); Cannot make a static reference to the non-static method getName() from the type Artist 

its my first time using APIs, and i started getting tired of these errors, please help

4 Answers 4

1

Like other said you need to Instantiate LastFmServer like

LastFmServer mLastFmServer= new LastFmServer(); 

and then called you method like

Artist[] artist = mLastFmServer.searchForArtist("hatebreed"); 
Sign up to request clarification or add additional context in comments.

3 Comments

if I do that i get "Cannot instantiate the type LastFmServer" error in your first line :( but this doesnt give any error: LastFmServer server = AndroidLastFmServerFactory.getServer();
I guess you are able to solve this problem stackoverflow.com/q/11924018/1436931..so now what is your problem? The main problem is, as also mentioned by others that you need to instantiate the LastFmServer with some Default settings
After solving the problem from link it seems that i got it working... Thanks
0

You have to instantiate a LastFmServer and Artist with new (or the appropriate factory method.

1 Comment

is this ok? LastFmServer server = AndroidLastFmServerFactory.getServer();
0

You have to call the methods through a object and not make a static reference.

I'm guessing you'd create an LastFmServer like so (depending on the constructor).

LastFmServer object = new LastFmServer(); 

I hope this helps.

Comments

0

You need to instantiate the respective objects of LastFmServer and Artist by using new.

LastFmServer lastFmServerObj = new LastFmServer(); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.