Retrofti 2:找到多个 Retrofit 注释,只允许一个。 (参数#1)

Retrofti 2: Multiple Retrofit annotations found, only one allowed. (parameter #1)

我在 Retrofit 2 中构建请求时遇到了一些 trouble/confusion,以下是我的问题,即;有人可以建议如何在构建请求

时添加以下“payload?file
BaseUrl : https://testserver.testbox.com/

Full URL : https://testserver.testbox.com/payload?file=Config/testApp_Android_3.2_IN_config.json


@GET("Config/testApp_Android_{version}_{country}_config.json")
                    fun getConfig(
                        @Query("file")
                        @Path("version") applicationVersion: String,
                        @Path("country") applicationCountry: String
                    ): Observable<Config>

谢谢!

在您的 getConfig() 方法中创建一个文件名参数(或您喜欢的参数名称),如下所示:

BaseUrl : https://testserver.testbox.com/

Full URL : https://testserver.testbox.com/payload?file=Config/testApp_Android_3.2_IN_config.json


@GET("/payload")
fun getConfig(@Query("file") fileName:String): Observable<Config>

然后从调用 getConfig(fileName)

的 class 构建并传递 fileName 参数
var applicationVersion = "Android_3.2"
var applicationCountry = "IN"

val fileName = "Config/testApp_Android_$applicationVersion_$applicationCountry_config.json"
getConfig(fileName)