【问题标题】:java.lang.RuntimeException: Unable to invoke no-args constructor for retrofit2.Calljava.lang.RuntimeException:无法为 retrofit2.Call 调用无参数构造函数
【发布时间】:2020-06-15 02:10:11
【问题描述】:

向 Gson 注册此类型的 InstanceCreator 可能会解决此问题。

有人可以帮我吗?我需要从响应中捕获标头(授权令牌)。

val call: Call<GuestAuth> = api.getGuestAuthToken(AuthModel("guest"))

 call.enqueue(object : Callback<GuestAuth> {
                override fun onFailure(call: Call<GuestAuth>, t: Throwable) {
                    Log.e("retrofit", t.localizedMessage)
                }

                override fun onResponse(call: Call<GuestAuth>,response: Response<GuestAuth>) {
                    Log.e("retrofit", "OK")
                    data = response.body()
                    authorizationToken = response.headers().get("Authorization").toString()
                }
            })

堆栈溢出之前的问题都没有帮助我:(

【问题讨论】:

    标签: java android kotlin coroutine retrofit2.6


    【解决方案1】:

    也许这个帖子可以帮助你:https://github.com/square/retrofit/issues/3226

    请提供有关您的代码的更多详细信息。

    【讨论】:

      猜你喜欢
      • 2020-02-14
      • 2019-08-24
      • 2019-10-19
      • 2018-12-29
      • 2015-08-02
      • 2019-05-07
      • 2022-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多