wcs__1349 2019-03-13 11:17
浏览 1271

proguard+retrofit2.4+adapter-rxjava2-2.4.0+rxjava2+rxandroid2

目前在做android的代码混淆,没有混淆之前,代码运行正常,当打开混淆之后,代码运行时出现如下差错:

03-13 10:39:59.936  6285  6285 E AndroidRuntime: java.lang.IllegalArgumentException: Unable to create call adapter for class io.reactivex.b
03-13 10:39:59.936  6285  6285 E AndroidRuntime:     for method RequestApis.getCameraInfo
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at retrofit2.ServiceMethod$Builder.methodError()
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at retrofit2.ServiceMethod$Builder.createCallAdapter()
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at retrofit2.ServiceMethod$Builder.build()
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at retrofit2.Retrofit.loadServiceMethod()
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at retrofit2.Retrofit$1.invoke()
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at java.lang.reflect.Proxy.invoke(Proxy.java:393)
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at $Proxy0.getCameraInfo(Unknown Source)
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at com.xxx.helper.RetrofitHelper.getCameraInfo()
......
03-13 10:39:59.936  6285  6285 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Flowable return type must be parameterized as Flowable<Foo> or Flowable<? extends Foo>
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory.get()
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at retrofit2.Retrofit.nextCallAdapter()
03-13 10:39:59.936  6285  6285 E AndroidRuntime:    at retrofit2.Retrofit.callAdapter()

其中proguard配置:
# Retrofit
-dontwarn retrofit2.**
-dontwarn org.codehaus.mojo.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepattributes *Annotation*

# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
-dontnote retrofit2.Platform$IOS$MainThreadExecutor
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions

-dontwarn retrofit2.adapter.rxjava.CompletableHelper$** # https://github.com/square/retrofit/issues/2034
#To use Single instead of Observable in Retrofit interface
-keepnames class rx.Single
#Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod
# Retain service method parameters when optimizing.
-keepclassmembers,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}

-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeInvisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
-keepattributes RuntimeInvisibleParameterAnnotations

-keepattributes EnclosingMethod

-keepclasseswithmembers interface * {
    @retrofit2.* <methods>;
}

-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}

# OkHttp3
-keepattributes Signature
-keepattributes *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }

-dontwarn okhttp3.**

#OkHttp
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }

-dontwarn com.squareup.okhttp.**
-dontwarn okio.**

jar版本:
adapter-rxjava2-2.4.0.jar
retrofit-2.4.0.jar
reactive-streams-1.0.2.jar
rxjava-2.1.14.jar
rxandroid-2.0.2.aar

有哪位大神帮忙看下,如何解决?

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值