title: Retrofit 2 -API declarations must be interfaces
body: <p>I am trying to abstract the Retrofit complexity to an class named BaseService2 and all the classes that need to consume a webservice need to extend from that class, but i keep getting this error even with me passing an interface to the method retro.create(iWs::class.java), the iWs is an interface.</p>
  <p>Test method:</p>
  <pre><code>  @Test
  fun consultar_pedidos_test() {
      val pedidoService = PedidoService()
      pedidoService.consultarPedidos(205, null) {
          it.message
          it.statusCode
      }
  
      try {
          Thread.sleep(10 * 1000.toLong())
      } catch (e: InterruptedException) {
          e.printStackTrace()
      }
  }
  </code></pre>
  <p>Class that need to consume an webservice:</p>
  <pre><code>class PedidoService : BaseService2&lt;IPedidoService&gt;(IPedidoService::class.java) {
  
  fun consultarPedidos(codVendedor: Int, codRede: Int?, handler: (IResponse) -&gt; Unit) =
      execute(handler, (service as IPedidoService).getPedidosCarteira(codVendedor, codRede)) }
  </code></pre>
  <p>Class BaseService 2 that i use to abstract the retrofit complexity:</p>
  <pre><code>open class BaseService2&lt;T&gt;(iWs: Class&lt;T&gt;) {
  
  lateinit var handler: (IResponse) -&gt; Unit
  lateinit var call: Call&lt;IResponse&gt;
  var service: Class&lt;T&gt;
  
  init {
      val retro: Retrofit = Retrofit.Builder()
              .baseUrl(&quot;http://10.2.10.43:3000/&quot;)
              .addConverterFactory(GsonConverterFactory.create())
              //.client(httpClient.build())
              .build()
  
      service = retro.create(iWs::class.java)
  }
  
  fun execute(handler: (IResponse) -&gt; Unit, call: Call&lt;IResponse&gt;) {
      this.handler = handler
      this.call = call
  
      call.enqueue(object : Callback&lt;IResponse&gt; {
          override fun onResponse(call: Call&lt;IResponse&gt;, response: Response&lt;IResponse&gt;) {
              val pedido = response.body()
              handler.execute()
          }
  
          override fun onFailure(call: Call&lt;IResponse&gt;, t: Throwable) {
              Log.i(Constants.TAG.value, &quot;test onFailure&quot;)
          }
      })
  }
  </code></pre>
  <p>}</p>
  <p>Interface with the webservices:</p>
  <pre><code>interface IPedidoService {
  
  @GET(&quot;pedidos&quot;)
  fun getPedidosCarteira(
          @Query(&quot;codVendedor&quot;) codVendedor: Int?,
          @Query(&quot;codRede&quot;) codRede: Int?): Call&lt;IResponse&gt;
  </code></pre>
  <p>}</p>
  <p>Stacktrace:</p>
  <pre><code>java.lang.IllegalArgumentException: API declarations must be interfaces.
  at retrofit2.Retrofit.validateServiceInterface(Retrofit.java:156)
  at retrofit2.Retrofit.create(Retrofit.java:134)
  at br.com.mili.isisav.model.service.BaseService2.&lt;init&gt;(BaseService2.kt:23)
  at br.com.mili.isisav.model.service.pedidoCarteira.PedidoService.&lt;init&gt;(PedidoService.kt:6)
  at br.com.mili.isisav.retrofit.RetrofitTest.consultar_pedidos_test(RetrofitTest.kt:66)
  at java.lang.reflect.Method.invoke(Native Method)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.junit.runners.Suite.runChild(Suite.java:128)
  at org.junit.runners.Suite.runChild(Suite.java:27)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
  at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
  at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:388)
  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2205)
  </code></pre>
  <p>Also i accept suggetions on how to make this kind of abstraction on a different/better way, to simplify the use of this library.</p>