Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No type arguments expected for class Call

Tags:

android

kotlin

I'm having an issue.I have project and then i copy paste into an other new project and i'm facing this error

No type arguments expected for class Call

In the first project i didn't have any problem... Here is my interface class which i have the error

interface ApiInterface {
    @GET("data/2.5/weather?q=Prague")
    fun getWeatherData(@Query("units") units: String,
                       @Query("appid") appId: String)
            :Call<WeatherData> //here is the error

}

and here is my WeatherData class

data class WeatherData(
        @SerializedName("coord") val coord: Coord,
        @SerializedName("weather") val weather: List<Weather>,
        @SerializedName("base") val base: String,
        @SerializedName("main") val main: TemperatureData,
        @SerializedName("visibility") val visibility: Int,
        @SerializedName("wind") val wind: Wind,
        @SerializedName("clouds") val clouds: Clouds,
        @SerializedName("dt") val dt: Int,
        @SerializedName("sys") val sys: Sys,
        @SerializedName("id") val id: Int,
        @SerializedName("name") val name: String,
        @SerializedName("cod") val cod: Int
)

data class Sys(
        @SerializedName("type") val type: Int,
        @SerializedName("id") val id: Int,
        @SerializedName("message") val message: Double,
        @SerializedName("country") val country: String,
        @SerializedName("sunrise") val sunrise: Int,
        @SerializedName("sunset") val sunset: Int
)

data class Coord(
        @SerializedName("lon") val lon: Double,
        @SerializedName("lat") val lat: Double
)

data class TemperatureData(
        @SerializedName("temp") val temp: Double,
        @SerializedName("pressure") val pressure: Int,
        @SerializedName("humidity") val humidity: Int,
        @SerializedName("temp_min") val tempMin: Double,
        @SerializedName("temp_max") val tempMax: Double
)

data class Weather(
        @SerializedName("id") val id: Int,
        @SerializedName("main") val main: String,
        @SerializedName("description") val description: String,
        @SerializedName("icon") val icon: String
)

data class Clouds(
        @SerializedName("all") val all: Int
)

data class Wind(
        @SerializedName("speed") val speed: Double,
        @SerializedName("deg") val deg: Int
like image 367
Alex Kolydas Avatar asked Aug 18 '18 09:08

Alex Kolydas


3 Answers

Just verify that you've imported the correct package from Retrofit.

The correct one is

retrofit2.Call

not to be confused with, for example

android.telecom.Call
like image 82
Ollaw Avatar answered Sep 18 '22 12:09

Ollaw


Give a look to import section and check whether retrofit2.Call library is imported or not ,sometimes it gets touched with okhttp3.call but you have to use the retrofit one.so make sure the library is imported to the interface/class.

like image 20
Khalid Aziz Avatar answered Sep 22 '22 12:09

Khalid Aziz


If you import both Retrofit and Okhttp, make sure the Call class you use is the one from Retrofit:

import retrofit2.Call

not:

import okhttp3.Call
like image 44
Toda Avatar answered Sep 18 '22 12:09

Toda