I'm developing some applications and I want to connect them to a Restful WebService. To do that I wrote this class:
public class TagDS {
public TagDS(){
}
public boolean recordTag(Tag t){
try{
String send = t.getConteudo()+"\n"+t.getId()+"\n"+t.getURL()+"\n"+t.getData()+"\n"+t.getUser();
postService(send);
return true;
}catch(Exception e){
return false;
}
}
public void postService(String send) {
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service = client.resource(getBaseURI());
service.path("rest").path("project").path("create").path(send).accept(MediaType.TEXT_PLAIN).post();
}
private static URI getBaseURI() {
return UriBuilder.fromUri(
"http://localhost:8080/pt.Android.Project.WebService").build();
}
}
But when I run the application, is displayed the menssage:
<p>08-16 10:24:33.280: E/AndroidRuntime(24149): FATAL EXCEPTION: main </p>
<p>08-16 10:24:33.280: E/AndroidRuntime(24149): java.lang.NoClassDefFoundError: com.sun.jersey.api.client.config.DefaultClientConfig</p>
I have all the libraries added to the project. My question is: Is it possible that libraries are not loaded when we are creating a apk?
I have tested my WebService separatly and it works normally. I thought "maby the problem was android permissions" but I searched and I have the permission:
<user-permission android:name="android.permission.INTERNET" />
Can you help me?
Sincerely, Rita