2016-03-11 5 views
2

J'ai cherché des exemples de Robospice + Retrofit 2 sur internet mais je n'ai rien trouvé. Je construis un exemple moi-même, mais a l'exception suivante:Robospice + Retrofit 2: assignation d'un convertisseur

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 

Je pense que l'erreur est parce que je ne l'ai pas affecté un Converter. Mais en essayant de déclarer un Converter le type de retour de la méthode est de 1 Rénovation:

enter image description here

Cela me fait penser que n'est pas possible d'utiliser 2 Retrofit avec Robospice.

Ai-je raison? Peut-on faire quelque chose à ce sujet?

Merci d'avance.

+2

Ceci est brièvement discuté par l'un des développeurs dans la [question suivante sur github] (https://github.com/stephanenicolas/robospice/issues/443) (et aussi dans ce [ autre ancien problème] (https://github.com/stephanenicolas/robospice/issues/396)). ** Longue histoire courte ** - pas pour le moment; cela nécessite des efforts de développement non négligeables; les devs originaux sont trop occupés pour le mettre à jour; il y a des personnes qui s'intéressent à l'avenir de la bibliothèque mais qui doivent être organisées. –

+1

Selon le contributeur robotique mykolaj, son extension retrofit2 fonctionne de manière stable dans son projet ....... l'effort principal dont parle Dev-iL semble être la mise en œuvre de la persistance du cache ... Quoi qu'il en soit, jetez un oeil à: https://github.com/mykolaj/robospice/tree/develop/extensions/robospice-retrofit2-parent Et un exemple d'application pour l'extension: https://github.com/mykolaj/Robospice-Retrofit2-sample – Stilzk1n

+0

S'il existe déjà un La mise en œuvre de Retrofit 2, serait mieux si vous faites votre commentaire une réponse, de sorte que je peux le mettre comme la réponse acceptée. –

Répondre

1

Ce n'est pas encore possible. Mais les gens sont asking for it. Du développeur:

... personnellement je ne pouvais pas trouver le temps de maintenir la lib comme j'ai été impliqué dans d'autres projets OSS. Les contributeurs sont les bienvenus.

Stéphane