Robospice + Retrofit 2: assigning a Converter

526 Views Asked by At

I have looked for examples of Robospice + Retrofit 2 in the internet but I couldn't find anything. I am building an example myself but got the following exception:

9:40:56.516 3553-3553/? E/AndroidRuntime: FATAL EXCEPTION: main
     Process: com.carlos.robospiceexample, PID: 3553
     java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit/converter/GsonConverter;
         at com.octo.android.robospice.retrofit.RetrofitGsonSpiceService.createConverter(RetrofitGsonSpiceService.java:37)
         at com.octo.android.robospice.retrofit.RetrofitSpiceService.getConverter(RetrofitSpiceService.java:42)
         at com.octo.android.robospice.retrofit.RetrofitGsonSpiceService.createCacheManager(RetrofitGsonSpiceService.java:31)
         at com.octo.android.robospice.SpiceService.onCreate(SpiceService.java:108)
         at com.octo.android.robospice.retrofit.RetrofitSpiceService.onCreate(RetrofitSpiceService.java:27)
         at com.carlos.robospiceexample.SampleRetrofitSpiceService.onCreate(SampleRetrofitSpiceService.java:14)
         at android.app.ActivityThread.handleCreateService(ActivityThread.java:2761)
         at android.app.ActivityThread.access$1800(ActivityThread.java:151)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386)
         at android.os.Handler.dispatchMessage(Handler.java:102)
         at android.os.Looper.loop(Looper.java:135)
         at android.app.ActivityThread.main(ActivityThread.java:5254)
         at java.lang.reflect.Method.invoke(Native Method)
         at java.lang.reflect.Method.invoke(Method.java:372)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
      Caused by: java.lang.ClassNotFoundException: Didn't find class "retrofit.converter.GsonConverter" on path:
             DexPathList[[zip file "/data/app/com.carlos.robospiceexample-1/base.apk"],
             nativeLibraryDirectories=[/vendor/lib, /system/lib]]
         at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
         at com.octo.android.robospice.retrofit.RetrofitGsonSpiceService.createConverter(RetrofitGsonSpiceService.java:37) 
         at com.octo.android.robospice.retrofit.RetrofitSpiceService.getConverter(RetrofitSpiceService.java:42) 
         at com.octo.android.robospice.retrofit.RetrofitGsonSpiceService.createCacheManager(RetrofitGsonSpiceService.java:31) 
         at com.octo.android.robospice.SpiceService.onCreate(SpiceService.java:108) 
         at com.octo.android.robospice.retrofit.RetrofitSpiceService.onCreate(RetrofitSpiceService.java:27) 
         at com.carlos.robospiceexample.SampleRetrofitSpiceService.onCreate(SampleRetrofitSpiceService.java:14) 
         at android.app.ActivityThread.handleCreateService(ActivityThread.java:2761) 
         at android.app.ActivityThread.access$1800(ActivityThread.java:151) 
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386) 
         at android.os.Handler.dispatchMessage(Handler.java:102) 
         at android.os.Looper.loop(Looper.java:135) 
         at android.app.ActivityThread.main(ActivityThread.java:5254) 
         at java.lang.reflect.Method.invoke(Native Method) 
         at java.lang.reflect.Method.invoke(Method.java:372) 
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
        Suppressed: java.lang.ClassNotFoundException: retrofit.converter.GsonConverter
         at java.lang.Class.classForName(Native Method)
         at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
         at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                ... 17 more
      Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
03-11 09:40:56.519 3553-3553/? I/Process: Sending signal. PID: 3553 SIG: 9

I think the error is because I haven't assigned a Converter. But when trying to declare a Converter the return type of the method is from Retrofit 1:

enter image description here

That makes me think that is not possible to use Retrofit 2 with Robospice.

Am I right? Can anything be done about this?

Thanks in advance.

1

There are 1 best solutions below

0
Alexander Suraphel On

It's not possible yet. But people are asking for it. From the developer:

...personnally I couldn't find time to maintain the lib as I have been involved in other OSS projects. Contributors are welcome.

Stéphane