Android java.lang.IllegalArgumentException:未找到改装注释。(参数#4)

Android java.lang.IllegalArgumentException:未找到改装注释。(参数#4),android,kotlin,mvvm,retrofit,Android,Kotlin,Mvvm,Retrofit,我正在尝试连接到REST API端点 下面是我的WebService.kt package <package_name>.data.services import ch.iazi.paidrent.BuildConfig import ch.iazi.paidrent.models.DefaultParameters import retrofit2.Response import retrofit2.http.GET import retrofit2.http.Headers i

我正在尝试连接到REST API端点

下面是我的WebService.kt

package <package_name>.data.services

import ch.iazi.paidrent.BuildConfig
import ch.iazi.paidrent.models.DefaultParameters
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.Query

interface WebService {

    companion object{
         const val ENDPOINT_DEFAULT_PARAMETERS = "/appDefaultParameterValues"
    }

   @Headers("Content-Type: application/x-www-form-urlencoded")
   @GET(BuildConfig.APPVERSION + ENDPOINT_DEFAULT_PARAMETERS)
   suspend fun getDefaultParameters(
      @Query("app") app: String,
      @Query("tid") tid: Long,
      @Query("uid") uid: String
   ): Response<DefaultParameters>

}
package.data.services
导入ch.iazi.paidrent.BuildConfig
导入ch.iazi.paidrent.models.DefaultParameters
2.回应
导入文件2.http.GET
导入2.http.Headers
导入文件2.http.Query
接口Web服务{
伴星{
const val ENDPOINT_DEFAULT_PARAMETERS=“/appDefaultParameterValues”
}
@标题(“内容类型:application/x-www-form-urlencoded”)
@获取(BuildConfig.APPVERSION+端点\默认\参数)
挂起getDefaultParameters(
@查询(“应用程序”)应用程序:字符串,
@查询(“tid”)tid:Long,
@查询(“uid”)uid:String
):回应
}
这是我的Repository.kt-

package <package_name>.data

import androidx.lifecycle.LiveData
import <package_name>.data.services.ServiceBuilder
import <package_name>.data.services.WebService
import <package_name>.models.DefaultParameters
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch

object Repository{

    val API = ServiceBuilder.buildWebService(WebService::class.java)

    fun getDefaultParameters(app:String,tid:Long,uid:String):LiveData<DefaultParameters>{
        return object : LiveData<DefaultParameters>(){
            override fun onActive() {
                super.onActive()
                CoroutineScope(IO).launch {
                    val response = API.getDefaultParameters(app,tid,uid)
                    print(response)
                }
            }
        }
    }

}
package.data
导入androidx.lifecycle.LiveData
import.data.services.ServiceBuilder
import.data.services.WebService
import.models.DefaultParameters
导入kotlinx.coroutines.CoroutineScope
导入kotlinx.coroutines.Dispatchers.IO
导入kotlinx.coroutines.launch
对象存储库{
val API=ServiceBuilder.buildWebService(WebService::class.java)
fun getDefaultParameters(app:String,tid:Long,uid:String):LiveData{
返回对象:LiveData(){
override-onActive(){
super.onActive()
协同观测(IO).发射{
val response=API.getDefaultParameters(应用程序、tid、uid)
打印(答复)
}
}
}
}
}
这是我调用存储库中的方法时的日志:-

2020-03-02 15:15:48.112 13174-13251/<package_name> E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
    Process: <package_name>, PID: 13174
    java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #4)
        for method WebService.getDefaultParameters
        at retrofit2.Utils.methodError(Utils.java:52)
        at retrofit2.Utils.methodError(Utils.java:42)
        at retrofit2.Utils.parameterError(Utils.java:61)
        at retrofit2.RequestFactory$Builder.parseParameter(RequestFactory.java:311)
        at retrofit2.RequestFactory$Builder.build(RequestFactory.java:182)
        at retrofit2.RequestFactory.parseAnnotations(RequestFactory.java:65)
        at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:25)
        at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:168)
        at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
        at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
        at $Proxy1.getDefaultParameters(Unknown Source)
        at ch.iazi.paidrent.data.Repository$getDefaultParameters$1$onActive$1.invokeSuspend(Repository.kt:20)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)
2020-03-02 15:15:48.112 13174-13251/E/AndroidRuntime:致命异常:DefaultDispatcher-worker-1
进程:,PID:13174
java.lang.IllegalArgumentException:未找到改装注释。(参数#4)
对于方法WebService.getDefaultParameters
在2.Utils.methodError处(Utils.java:52)
在2.Utils.methodError处(Utils.java:42)
at.Utils.parameterError(Utils.java:61)
在2.RequestFactory$Builder.parseParameter处(RequestFactory.java:311)
在2.RequestFactory$Builder.build处(RequestFactory.java:182)
在2.RequestFactory.parseAnnotations(RequestFactory.java:65)
位于2.ServiceMethod.parseAnnotations(ServiceMethod.java:25)
在Refundation2.Refundation.loadServiceMethod(Refundation.java:168)中
在reformation2.reformation$1.invoke(reformation.java:147)
位于java.lang.reflect.Proxy.invoke(Proxy.java:1006)
位于$Proxy1.getDefaultParameters(未知源)
在ch.iazi.paidrent.data.Repository$getDefaultParameters$1$onActive$1.invokeSuspend(Repository.kt:20)
位于kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
在kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
在kotlinx.coroutines.scheduling.CoroutineScheduler.runsafe(CoroutineScheduler.kt:594)
在kotlinx.coroutines.scheduling.CoroutineScheduler.access$runsafe(CoroutineScheduler.kt:60)
在kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)
我已经用@Query annotation注释了接口定义中的所有3个参数。 日志消息显示参数#4。但是,我的端点调用中没有4个参数。
我在这里遗漏了什么吗?

通过在build.gradle中将改装版本从2.5.0升级到2.6.0,解决了这个问题。 从版本2.6.0开始,支持Kotlin协同程序

谢谢