0

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

Chirag
  • 56,621
  • 29
  • 151
  • 198
Rita
  • 1
  • 1
  • 3

1 Answers1

0

Why would you need jersey to access a web service from android? Not all java libraries are supported by android's version of 'java-like' virtual machine.

devmiles.com
  • 9,895
  • 5
  • 31
  • 47
  • Hum.. I tried to do with HttpClient but without success so I made it with the jersey. When I did with the HttpClient I could read but I couldn't do a post, so I gave up I wrote with jersey, – Rita Aug 16 '12 at 13:15
  • looks like jersey isn't supported: http://stackoverflow.com/questions/6127997/use-jersey-library-in-a-android-project – devmiles.com Aug 16 '12 at 13:16
  • Seriously! :S I tried with HTTPClient but without success! Someone can give some tips who to do a post with httpClient.. I tried but didn't work! :S I I already saw a lot's of tuts. But they have only gets! I can show my code! – Rita Aug 16 '12 at 13:20
  • you should post another question about that and close this one. – devmiles.com Aug 16 '12 at 13:21