我正在尝试将 kotlinx.serialization 库与改造和协程一起使用。除非我尝试使用 proguard,否则这种组合工作正常。
我的proguard规则。
-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.SerializationKt
-keep,includedescriptorclasses class com.myapp.data.**$$serializer { *; }
-keepclassmembers class com.myapp.data.* {
*** Companion;
}
-keepclasseswithmembers class com.myapp.data.* {
kotlinx.serialization.KSerializer serializer(...);
}
-keepclasseswithmembers class com.myapp.data.features.featurename.entities.* { *; }
这是例外。
java.lang.IllegalArgumentException: Unable to create converter for class e.f.a.d.c.b.a
for method a.b
at retrofit2.x.n(SourceFile:54)
at retrofit2.j.e(SourceFile:126)
at retrofit2.j.f(SourceFile:85)
at retrofit2.u.b(SourceFile:39)
at retrofit2.t.c(SourceFile:202)
at retrofit2.t$a.invoke(SourceFile:160)
at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at $Proxy13.b(Unknown Source)
at com.myapp.api.n.c$e.invokeSuspend(SourceFile:49)
at com.myapp.api.n.c$e.invoke(Unknown Source:10)
at com.myapp.api.a.e(SourceFile:44)
at com.myapp.api.n.c.b(SourceFile:48)
at com.myapp.ui.splash.c$b.invokeSuspend(SourceFile:122)
at kotlin.t.j.a.a.resumeWith(SourceFile:33)
at kotlinx.coroutines.z0.run(SourceFile:56)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: kotlinx.serialization.SerializationException: Can't locate argument-less serializer for class a. For generic classes, such as lists, please provide serializer explicitly.
at kotlinx.serialization.h.a(SourceFile:21)
at kotlinx.serialization.g.a(SourceFile:56)
at e.e.c.b.a.a.b.d(SourceFile:23)
at retrofit2.t.g(SourceFile:362)
at retrofit2.t.i(SourceFile:345)
at retrofit2.j.e(SourceFile:124)
at retrofit2.j.f(SourceFile:85)
at retrofit2.u.b(SourceFile:39)
at retrofit2.t.c(SourceFile:202)
at retrofit2.t$a.invoke(SourceFile:160)
at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at $Proxy13.b(Unknown Source)
at com.myapp.api.n.c$e.invokeSuspend(SourceFile:49)
at com.myapp.api.n.c$e.invoke(Unknown Source:10)
at com.myapp.api.a.e(SourceFile:44)
at com.myapp.api.n.c.b(SourceFile:48)
at com.myapp.ui.splash.c$b.invokeSuspend(SourceFile:122)
at kotlin.t.j.a.a.resumeWith(SourceFile:33)
at kotlinx.coroutines.z0.run(SourceFile:56)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
科特林版本 1.3.72
kotlinx.serializarion 版本 0.20.0
retrofit2-kotlinx-序列化转换器 0.5.0
我将不胜感激在这方面的任何帮助。