【发布时间】:2019-09-05 15:12:51
【问题描述】:
我将kotlin 用于带有databinding 和MVVM 模式的android。
Retrofit2 发送和获取 api 调用。
当我发送登录呼叫时,我总是崩溃,这是消息:
java.lang.IllegalArgumentException: Unable to create call adapter for class java.lang.Object
我多次重新设计响应,它实际上与我的 api 的响应相匹配。 请问有什么帮助吗?
//my retrofit interface
interface RetrofitInterface {
@FormUrlEncoded
@POST("userLogin")
suspend fun userLogin(
@Field("userName") userName: String,
@Field("userPassword") userPassword: String
): Response<UserLoginResponse>
companion object {
operator fun invoke(
networkConnectionInterceptor: NetworkConnectionInterceptor
): RetrofitInterface {
val okHttpClient = OkHttpClient.Builder()
.addInterceptor(networkConnectionInterceptor)
.build()
return Retrofit.Builder()
.client(okHttpClient)
.baseUrl("http://muUrlIsCorrect/")
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(RetrofitInterface::class.java)
}
}
}
//My response class
data class UserLoginResponse(
var error: Boolean?,
var message: String?,
var user: User?
)
【问题讨论】:
-
发布完整的堆栈跟踪
-
完整的堆栈跟踪是什么意思?
-
在 LogCat 中,发布堆栈跟踪错误。
-
是的,请给我一分钟。
-
我不能全部发布!!!!!!!!!
标签: android api kotlin data-binding retrofit2