gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:53:21 28 4
gpt4 key购买 nike

我正在使用改造 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<Foo> or Observable<? extends Foo>
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime: at retrofit.RxJavaCallAdapterFactory.get(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime: at retrofit.Retrofit.nextCallAdapter(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime: at retrofit.Retrofit.callAdapter(Unknown Source)
11-17 18:23:22.752 16274-16274/ph.reggis.FEDT E/AndroidRuntime: ... 28 more

接口(interface):

@GET("news")
Observable<News> getNews();

fragment :

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

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

//Observable<News> observable = fmService.getNews();
//subscription = observable. - ALSO NOT WORKING

subscription = fmService.getNews().
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(appController.getDefaultScheduler())
.subscribe(new Subscriber<News>() {...

Gradle :

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"

混淆器:

# 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 ----------

关于android - Observable 返回类型必须参数化为 Observable<Foo> 或 Observable<?扩展 Foo>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33755077/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com