lyfe-android
lyfe2024 / lyfe-android Goto Github PK
View Code? Open in Web Editor NEWlyfe-android
lyfe-android
Retrofit으로 리퀘스트를 보내는거 까지는 성공하는데 Response를 받아오는 과정에서 Serializer가 제대로 작동하지 않는다는 메세지와 함께 앱이 크래쉬됩니다.
[에러 메세지]
FATAL EXCEPTION: main
Process: com.lyfe.android, PID: 13755
java.lang.IllegalArgumentException: Unable to create converter for class com.lyfe.android.core.data.model.GoogleTokenResponse
for method GoogleService.getAccessToken
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 java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at $Proxy6.getAccessToken(Unknown Source)
at com.lyfe.android.core.data.datasource.GoogleDataSourceImpl.getAccessToken(GoogleDataSourceImpl.kt:20)
at com.lyfe.android.core.data.repository.GoogleRepositoryImpl$getAccessToken$2.invokeSuspend(GoogleRepositoryImpl.kt:22)
at com.lyfe.android.core.data.repository.GoogleRepositoryImpl$getAccessToken$2.invoke(Unknown Source:8)
at com.lyfe.android.core.data.repository.GoogleRepositoryImpl$getAccessToken$2.invoke(Unknown Source:4)
at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:230)
at kotlinx.coroutines.flow.internal.ChannelFlowOperatorImpl.flowCollect(ChannelFlow.kt:195)
at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo$suspendImpl(ChannelFlow.kt:157)
at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo(Unknown Source:0)
at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:60)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@5f25db1, Dispatchers.Main.immediate]
Caused by: kotlinx.serialization.SerializationException: Serializer for class 'GoogleTokenResponse' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
at kotlinx.serialization.internal.PlatformKt.serializerNotRegistered(Platform.kt:31)
at kotlinx.serialization.SerializersKt__SerializersJvmKt.serializer(SerializersJvm.kt:77)
at kotlinx.serialization.SerializersKt.serializer(Unknown Source:1)
at com.lyfe.android.core.data.network.converter.LyfeSerializer.serializer(LyfeSerializer.kt:22)
at com.lyfe.android.core.data.network.converter.SerializerFactory.responseBodyConverter(SerializerFactory.kt:24)
at retrofit2.Retrofit.nextResponseBodyConverter(Retrofit.java:362)
at retrofit2.Retrofit.responseBodyConverter(Retrofit.java:345)
at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:124)
... 24 more
[관련 코드]
원래 아래 쪽 코드 googleService.getAccessToken(request)
였는데 이때 Request를 Serialize하는 과정에서 오류가 발생해 아래와 같이 고쳤더니 이번에는 Response에서 오류가 발생하고 있습니다.
override suspend fun getAccessToken(request: GoogleTokenRequest): Result<GoogleTokenResponse> {
Log.d("Google Request", request.toString())
return googleService.getAccessToken(request.toString())
}
@Serializable
data class GoogleTokenRequest(
private val grant_type: String,
private val client_id: String,
private val client_secret: String,
private val code: String
)
@Serializable
data class GoogleTokenResponse(
val access_token: String
)
구글링해서 비슷한 오류에 대한 해결방법들 적용해보고 있긴한데 모두 해결이 안되서 Kotlin Serializer가 아닌 다른 곳에서 에러가 났을 가능성도 있을 거 같습니다.
혼자서 3시간정도 삽질하다가 너무 시간 오래 잡아먹혀서... 혹시 아는 정보가 있으실까봐 도움 구합니다...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.