I\'m writing an Android app that access the internet. It runs without error, but ever since I upgraded my device (Samsung Galaxy S5) to Android 5.0.1 my logcat is flooded wi
Solution:
Add in your application
tag:
android:usesCleartextTraffic="true"
As follows:
<application
....
android:usesCleartextTraffic="true"
....>
You can use the regex filter to hide the log message flooding your log:
^((?!isSBSettingEnabled).)*$
You can also hide more than one offending log by using |
. For example
^((?!isSBSettingEnabled|OtherLog|OtherLog2|Annoying Messages).)*$
If you are using HttpLoggingInterceptor
on the application that runs on a Samsung device, just set the loglevel to the body, it will fix everything. Something like this should work fine:
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
A better solution is offered in Android 7.0 through network security configuration file. How to use it? 1. Add a network security config file under res/xml. 2. Add a domain config and set cleartextTrafficPermitted to “true”.
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">your_domain.com</domain>
</domain-config>
</network-security-config>
Add your network security config to your Android manifest file under application.
<application
android:name=".MyApplication"
android:networkSecurityConfig="@xml/network_security_config">
You are probably using a HttpUrlConnection
or a HttpsUrlConnection
. Maybe you can find out which class is logging by calling getClass()
on the corresponding connection and turn it off with the Logger.getLogger("...").setLevel(Level.OFF);
See also Enable logging for JDK class programmatically