Question

I'm creating an Android application which uses RoboSpice for asynchronous network calls. Although I have no experience with RoboSpice, I've chosen for RoboSpice as it's regarded as one of the best on the internet, and because it can automatically convert JSON to POJO's. Unfortunately, the quality of the documentation of RoboSpice is a bit poor. Therefore my question:

I've succesfully used RoboSpice to make a network call to a REST GET method, automatically parse the JSON to a POJO and show the list of retrieved objects in an Android ViewPager. I'm using Jackson2GoogleHttpClientSpiceService to do this. Now, in this ViewPager I'm showing an image as well. Obviously, I want to download this image using RoboSpice. I've used one of the RoboSpice examples (which uses the OkHttpBitmapSpiceManager to download an image) as a guide and according to that I've added this line to my activity:

private OkHttpBitmapSpiceManager spiceManagerBinary = new OkHttpBitmapSpiceManager();

Also, I've added this line to the manifest:

<service
        android:name="com.octo.android.robospice.spicelist.okhttp.OkHttpBitmapSpiceService"
        android:exported="false" />

Now, as I'm not using maven for my Android project, I had to add the following jar to my project: robospice-ui-spicelist-1.4.9.jar (I've obviously added all the other necessary jar's for using the Jackson2GoogleHttpClientSpiceService, which works).

The problem is, the application fails to even start. Whenever I remove (or comment) the line containing the new OkHttpBitmapSpiceManager() the application works flawlessly. So apparently calling the constructor is what makes the application crash. I get the following error from the logcat:

java.lang.NoClassDefFoundError: com.octo.android.robospice.spicelist.okhttp.OkHttpBitmapSpiceService

To me, this error seems to relate to a missing jar or something. But I've added all the necessary jar's according to the documentation. Can someone with experience of RoboSpice explain to me what I'm doing wrong here? Should I add more jar's or am I missing something else? Or should I even use a completely different approach to loading images from a URL using RoboSpice?


EDIT!

To make it more clear, I've added the following jar's to my libs folder and the build path:

  • commons-io-1.3.2.jar
  • commons-lang3-3.1.jar
  • google-http-client-1.17.0-rc.jar
  • google-http-client-android-1.17.0-rc.jar
  • google-http-client-jackson2-1.17.0-rc.jar
  • guava-jdk5-13.0.jar
  • jackson-core-2.1.3.jar
  • jsr305-1.3.9.jar
  • robospice-1.4.9.jar
  • robospice-cache-1.4.9.jar
  • robospice-google-http-client-1.4.9.jar
  • robospice-ui-spicelist-1.4.9.jar
Était-ce utile?

La solution

The problem is that you are not using a jar that contains the service class : com.octo.android.robospice.spicelist.okhttp.OkHttpBitmapSpiceService.

It is not contained in robospice-ui-spice-list but in robospice-okhttp. If you include this jar, you will get the service you need.

Have a look at this sample.

Also, please not that to download an image, it can be even easier to use non okhttp related classes. RS offers simple binary requests in its core package.

Oh, and btw, when you say "RS docs is a bit poor", please let us now via github or the mailing list how you would like to see it more complete. We also accept pull requests, even only for documentation.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top