Adicionei o httploggin e funcionou 1 ou 2 vezes, depois sumiu e não aparece mais, já olhei todos os passos, criei o emulador de novo, limpei cache, etc. Mas não aparece. Não consigo descobrir porque minha requisição falha no retrofit e funciona com o WebClient (conferi a url). Mas enfim, quero mesmo saber como ativar de novo o log do okhttp.
Classe Retrofit:
public class RetrofitConfig {
private final Retrofit retrofit;
public RetrofitConfig() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.level(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder client = new OkHttpClient.Builder();
client.addInterceptor(interceptor);
retrofit = new Retrofit.Builder()
.baseUrl("http://x.x.x.x:8080/rest/denuncias/")
.addConverterFactory(JacksonConverterFactory.create())
.client(client.build())
.build();
}
public DenunciaService getSinosiService() {
return retrofit.create(DenunciaService.class);
}
}
Interface Service
public interface DenunciaService {
@GET("listar")
Call<List<Denuncia>> buscarDenuncias();
@POST("denuncia")
Call<Void> enviarDenuncia(@Body Denuncia denuncia);
}
Método que pega o objeto repassar ao retrofit para executar o POST
private void enviarDenuncia() {
Denuncia denuncia = recuperarDenuncia();
denuncia.setDataDenuncia(null);
Call call = new RetrofitConfig().getSinosiService().enviarDenuncia(denuncia);
call.enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
Log.i("onResponse", "sucesso");
}
@Override
public void onFailure(Call call, Throwable t) {
Log.e("onFailure", "requisição falhou");
}
});
}
Saída do terminal
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@d57b925
W/m.lf.sinosinov: Accessing hidden method Landroid/widget/PopupWindow;->setEpicenterBounds(Landroid/graphics/Rect;)V (light greylist, linking)
W/m.lf.sinosinov: Accessing hidden method Landroid/widget/PopupWindow;->setClipToScreenEnabled(Z)V (light greylist, reflection)
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@ce0aede
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
I/System.out: AGUA
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@65ac429
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
D/EGL_emulation: eglMakeCurrent: 0xe694ab40: ver 2 0 (tinfo 0xeead1920)
W/Java7Support: Unable to load JDK7 types (annotations, java.nio.file.Path): no Java7 support added
W/m.lf.sinosinov: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setUseSessionTickets(Z)V (light greylist, reflection)
Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setHostname(Ljava/lang/String;)V (light greylist, reflection)
W/m.lf.sinosinov: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getAlpnSelectedProtocol()[B (light greylist, reflection)
Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setAlpnProtocols([B)V (light greylist, reflection)
W/m.lf.sinosinov: Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (light greylist, reflection)
Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (light greylist, reflection)
Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (light greylist, reflection)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
I/Choreographer: Skipped 32 frames! The application may be doing too much work on its main thread.
E/onFailure: requisição falhou