我正在尝试实现 here 中的示例在 Kotlin 。我在运行时收到此错误“原因:java.lang.IllegalArgumentException:接口(interface)定义不得扩展其他接口(interface)”。当 Kotlin 特征没有实现任何方法时,有什么方法可以将它们视为 java 接口(interface),或者我必须使用 java 接口(interface)?代码如下:
public trait RestAPI {
[GET("/weather")]
fun getList([Query("q")] place: String,
[Query("units")] units: String)
: Observable<WeatherData>
}
以及导致错误的调用:
val service = restAdapter?.create(javaClass<RestAPI>())
最佳答案
此问题已修复。我正在使用 Kotlin 版本 0.9.976 以这种方式实现的 Retrofit。
关于retrofit - Kotlin 特性和改造,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25650528/