android – Observable返回类型必须参数化为Observable或Observable

前端之家收集整理的这篇文章主要介绍了android – Observable返回类型必须参数化为Observable或Observable前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在使用改造2.0.0-beta2并且调试版本正常工作但我在使用Proguard进行发布版本时遇到以下错误.

这是更新的logcat错误.

11-17 18:23:22.751 16274-16274/ph.reggis.FEDT D/AndroidRuntime: Shutting down VM
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime: FATAL EXCEPTION: main
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime: Process: ph.reggis.FEDT,PID: 16274
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {ph.reggis.FEDT/ph.reggis.FEDT.view.activity.NotificationListActivity}: java.lang.IllegalArgumentException: Unable to create call adapter for class b.a
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     for method InsularFMService.getNews
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.app.ActivityThread.-wrap11(ActivityThread.java)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:  Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for class b.a
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     for method InsularFMService.getNews
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at retrofit.Utils.methodError(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at retrofit.MethodHandler.createCallAdapter(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at retrofit.MethodHandler.create(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at retrofit.Retrofit.loadMethodHandler(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at retrofit.Retrofit$1.invoke(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at java.lang.reflect.Proxy.invoke(Proxy.java:393)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at $Proxy0.getNews(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at ph.reggis.FEDT.b.C.d(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at ph.reggis.FEDT.view.fragment.NotificationListFragment.t(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at ph.reggis.FEDT.view.fragment.NotificationListFragment.l(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.support.v4.b.B.a(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.support.v4.b.B.a(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.support.v4.b.B.a(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.support.v4.b.B.i(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.support.v4.b.y.i(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.support.v4.b.t.onPostResume(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.support.v7.a.B.onPostResume(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.app.Activity.performResume(Activity.java:6336)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime:  Caused by: java.lang.IllegalStateException: Observable return type must be parameterized as Observable

接口:

@GET("news")
Observable

分段:

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl(Constant.WS_URL_BASE)
        .addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
        .build();

InsularFMService fmService = retrofit.create(InsularFMService.class);

//Observable

Graddle:

compile "com.squareup.retrofit:retrofit:2.0.0-beta2"
compile "com.squareup.retrofit:converter-gson:2.0.0-beta2"
compile "com.squareup.retrofit:adapter-rxjava:2.0.0-beta2"

Proguard的:

# Fixed: Caused by: java.lang.NoSuchFieldException: No field producerIndex
 -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
     long producerIndex;
     long consumerIndex;
 }
 -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
     long producerNode;
     long consumerNode;
}
最佳答案
现在它正在将这些属性放在Proguard中.

# Application classes that will be serialized/deserialized over Gson
-keep class ph.reggis.FEDT.model.api.** { *; }

这是完整的设置

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default,so configure it to keep all of it.
-keepattributes Signature
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class ph.reggis.FEDT.model.api.** { *; }

##---------------End: proguard configuration for Gson  ----------
原文链接:https://www.f2er.com/android/429898.html

猜你在找的Android相关文章