首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Robospice + Retrofit 2:分配转换器

Robospice + Retrofit 2:分配转换器
EN

Stack Overflow用户
提问于 2016-03-11 16:57:51
回答 1查看 497关注 0票数 2

我在互联网上寻找了Robospice + Retrofit 2的例子,但我什么也找不到。我自己构建了一个示例,但得到了以下异常:

代码语言:javascript
复制
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:

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

我说的对吗?对此我们能做些什么吗?

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2016-04-07 00:50:42

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

...personnally我找不到时间来维护这个库,因为我已经参与了其他开源项目。欢迎贡献者。

Stéphane

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35935909

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档