我正在编写一个API来从我的get服务中获取数据。我正在使用jersey客户端api来使用我的web服务。问题是当我运行应用程序时,我得到了这个错误:
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)我不知道问题出在哪里。下面是调用Client类的类:
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}
发布于 2012-10-23 11:08:32
这是一个内部Sun/Oracle API,在Android中不可用。Jersey或者你正在使用的任何库从一开始就不应该使用它。向他们提交一个bug,或者找到另一个库。
https://stackoverflow.com/questions/13022217
复制相似问题