I'm developing an android app in android Studio3 that its back is laravel. For the local server, I created a virtual server by artizan. Now the problem is connecting local server (127.0.0.1:8000) to android and for this, I tried too many baseUrl in bellow Interface like:
10.0.2.2:8008, 10.0.3.2:8000, IP4, ............., :/
Interface:
interface ApiInterface {
@GET("stocks.json")
fun getStocks(): Call<StockResponse>
companion object {
val BASE_URL = "http://192.168.1.106:8000/api/"
fun getClient(): ApiInterface{
val retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
return retrofit.create(ApiInterface::class.java)
}
}
}
And finally, I tried an external server for this project that it worked, But for local it didn't, So buddy, I would be appreciated if you resolve this distraught issue...
UPDATE: Guys thank you for your response, I really tried many ways and finally, I found out that laravel api routes fail in the android studio and it is not founded, It means:
http://192.168.1.106:8000/file.json (Worked-> specific file in local server )
http://192.168.1.106:8000/api/file (Not Worked-> laravel route api)