gpt4 book ai didi

android - 参数类型不得包含类型变量或通配符

转载 作者:行者123 更新时间:2023-12-04 12:17:14 28 4
gpt4 key购买 nike

在我的 android 应用程序中,我使用 Retrofit 2:

public enum OperationType {
@SerializedName("payment")
PAYMENT,
@SerializedName("payout")
PAYOUT,
@SerializedName("transfer")
TRANSFER
}




fun getOperationsList(typeList: List<OperationType>, callback: Callback<List<Operation>>) {
val call = myRestClient.getOperationsList(typeList)
executeRequest(call, callback)
}


@GET("/operations")
fun getOperationsList(@Query("type") typeList: List<OperationType>): Call<List<Operation>>

但我在这一行得到运行时错误:
val call = myRestClient.getOperationsList(typeList)

错误:
Shutting down VM
FATAL EXCEPTION: main
Process: md.qsystems.android.tango.debug, PID: 22714
java.lang.IllegalArgumentException: Parameter type must not include a type variable or wildcard: java.util.List<? extends OperationType> (parameter #1)
for method TangoRestClient.getOperationsList
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.validateResolvableType(RequestFactory.java:764)
at retrofit2.RequestFactory$Builder.parseParameterAnnotation(RequestFactory.java:401)
at retrofit2.RequestFactory$Builder.parseParameter(RequestFactory.java:306)
at retrofit2.RequestFactory$Builder.build(RequestFactory.java:193)
at retrofit2.RequestFactory.parseAnnotations(RequestFactory.java:67)
at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:26)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:149)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy1.getOperationsList(Unknown Source)
at mTransportService.getOperationsList(TransportService.kt:160)

最佳答案

You can add @JvmSuppressWildcards either inside the angle brackets before the String type, or before the List.Both should work and remove the wildcard.


解决方法取自 this issue .

关于android - 参数类型不得包含类型变量或通配符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57375401/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com