I am writing a API to get data from my webservices. I am using the jersey client api to consume my web services. The problem is when I run the application I am getting this error:
10-22 19:44:44.959: E/AndroidRuntime(13171): FATAL EXCEPTION: main
10-22 19:44:44.959: E/AndroidRuntime(13171): java.lang.NoClassDefFoundError:com.sun.jersey.api.client.Client
10-22 19:44:44.959: E/AndroidRuntime(13171): at com.ppsjamaica.data.DataManager.getAllUser(DataManager.java:54)
10-22 19:44:44.959: E/AndroidRuntime(13171): at com.ppsjamaica.MainActivity.onCreate(MainActivity.java:18)
10-22 19:44:44.959: E/AndroidRuntime(13171): at android.app.Activity.performCreate(Activity.java:4465)
I don’t have a clue what the problem is. Here is the class that invokes the Client class:
public class DataManager {
public Client client;
public DataManager ()
{
client = Client.create();
}
public List <User> getAllUser ()
{
WebResource webResource = client.resource(URL.URL_USERS_ALL);
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
if (response.getStatus () == 200)
{
return response.getEntity (new GenericType<List <User>> (){});
}
else
return null;
}//end getAllUser method
}
That’s an internal Sun/Oracle API and is not available in Android. Jersey or whatever library you are using shouldn’t be using it in the first place. File a bug with them or find another library.