https://kotlinlang.org logo
Title
c

chao.zhang

04/06/2023, 12:14 PM
Hello, I developed a tool using Composite Desktop. if execute ‘run’ commend,the tool is fine.but when i execute ‘runDistributable’, There will be an error. Has anyone knows what happened?
Exception in thread "DefaultDispatcher-worker-2" java.lang.IllegalArgumentException: Unable to create converter for class net.ModuleInfoResp0
    for method RetrofitService.getModuleInfo0
	at retrofit2.Utils.methodError(Utils.java:54)
	at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:126)
	at retrofit2.HttpServiceMethod.parseAnnotations(HttpServiceMethod.java:85)
	at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:39)
	at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:202)
	at retrofit2.Retrofit$1.invoke(Retrofit.java:160)
	at com.sun.proxy.$Proxy0.getModuleInfo0(Unknown Source)
	at net.RetrofitService$DefaultImpls.getModuleInfo0$default(RetrofitService.kt:17)
	at ui.Module0Kt$Module0$2$1.invokeSuspend(Module0.kt:23)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
	Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [androidx.compose.ui.awt.ComposeLayer$coroutineExceptionHandler$1@23bd828d, androidx.compose.runtime.BroadcastFrameClock@772580d1, StandaloneCoroutine{Cancelling}@3aa10bfa, <http://Dispatchers.IO]|Dispatchers.IO]>
Caused by: java.lang.IllegalArgumentException: cannot construct instances of net.ModuleInfoResp0
	at com.squareup.moshi.ClassFactory.get(ClassFactory.java:133)
	at com.squareup.moshi.ClassJsonAdapter$1.create(ClassJsonAdapter.java:79)
	at com.squareup.moshi.Moshi.adapter(Moshi.java:137)
	at com.squareup.moshi.Moshi.adapter(Moshi.java:97)
	at retrofit2.converter.moshi.MoshiConverterFactory.responseBodyConverter(MoshiConverterFactory.java:89)
	at retrofit2.Retrofit.nextResponseBodyConverter(Retrofit.java:362)
	at retrofit2.Retrofit.responseBodyConverter(Retrofit.java:345)
	at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:124)
	... 15 more
j

jw

04/06/2023, 12:41 PM
ProGuard is breaking your setup and you need some targeted rules to prevent that
c

chao.zhang

04/07/2023, 8:01 AM
At first, I thought ProGuard was causing the problem. then,I added this line of code
.addLast(KotlinJsonAdapterFactory())
No problem now🤣
Previously,
implementation("com.squareup.moshi:moshi-kotlin:1.14.0")
was not added