Search code examples
androidodatarestlet

Restlet createQuery fails with connection error (and after workaround NoSuchMethodError)


I followed the Android restlet tutorial and tried to consume a sample OData webservice (http://services.odata.org/OData/OData.svc/). When I create a query with myService.createProductQuery("/Products"); logcat tells me that

ERROR/org.restlet(700): Can't get the metadata for ...

A problem similar to this question. I did try and register the Apache client as suggested by Jerome Louvel:

Engine.getInstance().getRegisteredClients().clear();
Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null)); 

Unfortunately I get a new error. On Query initialization I get a NoSuchMethodError exception. The Query class seems to want to call MyService.getMetadatada(). From the docs I see this is a protected method on org.restlet.ext.odata.Service

Happens on version 2.0.11 and 2.1rc3 of Restlet.

Additionally I also tried a home-made .NET 4.0 WCF webservice, with the same results. Any help would be appreciated.


Solution

  • For future readers that come upon this question: just make double sure your Manifest file sets permission on your application to access the internet. (For shame). Obviously it needs access to the network to "call" the webservice.

    ..
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>