我在互联网上寻找过Robospice + Retrofit 2的示例,但找不到任何东西。我自己创建一个示例,但有以下异常:

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


我认为该错误是因为我尚未分配Converter。但是,当尝试声明Converter时,该方法的返回类型来自Retrofit 1:

android - Robospice +改造2:分配转换器-LMLPHP

这使我认为不可能将Retrofit 2与Robospice一起使用。

我对吗?对此可以采取任何措施吗?

提前致谢。

最佳答案

还不可能但是人们是asking for it。来自开发人员:


  ...就我个人而言,我找不到时间来维护lib
  参与其他OSS项目。欢迎贡献者。
  
  斯特凡

关于android - Robospice +改造2:分配转换器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35935909/

10-10 02:54