My Model
public class ModelMessage {
private String message;
public String getMessage() {
return message;
}
}
My Interface
public interface Noqta {
@GET("api/")
Call<ModelMessage> message();
}
My Call on Activity click
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://noqta.tk/")
.addConverterFactory(GsonConverterFactory.create())
.build();
Noqta noqta = retrofit.create(Noqta.class);
Call<ModelMessage> call = noqta.message();
call.enqueue(new Callback<ModelMessage>() {
@Override
public void onResponse(Call<ModelMessage> call, Response<ModelMessage> response) {
if(response.isSuccessful()){
tv.setText("True");
}else{
tv.setText("False");
}
}
@Override
public void onFailure(Call<ModelMessage> call, Throwable t) {
tv.setText("Error");
}
});
json body on noqta.tk/api
{"message":"Hello World from api web"}
What i am doing bad? I have internet permission on manifest
Add these two lines to your build.gradle in the android section:
android{
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
can someone explain to me why this is the solution? I see that the error is in:
.baseUrl("http://noqta.tk/")
Edit