I'm developing an Android application and I would like to have some way to print debug statements as my code runs. Fortunately for me, Logcat was able to print out Log.d messages when I run my application on an Android 2.3.3 (API 10) emulator.
However, when I tested the same exact application on a physical device (Samsung Galaxy S4 Android 4.2.2) I was unable to see anything other than dalvikvm and AndroidRuntime messages.
com.android.internal.os.RuntimeInit <<<<<<
07-28 04:49:24.165: DEBUG/AndroidRuntime(6378): CheckJNI is OFF
07-28 04:49:24.165: DEBUG/AndroidRuntime(6378): setted country_code = USA
07-28 04:49:24.165: DEBUG/AndroidRuntime(6378): setted countryiso_code = US
07-28 04:49:24.175: DEBUG/AndroidRuntime(6378): setted sales_code = VZW
07-28 04:49:24.175: DEBUG/AndroidRuntime(6378): readGMSProperty: start
07-28 04:49:24.175: DEBUG/AndroidRuntime(6378): readGMSProperty: already setted!!
07-28 04:49:24.175: DEBUG/AndroidRuntime(6378): readGMSProperty: end
07-28 04:49:24.175: DEBUG/AndroidRuntime(6378): addProductProperty: start
07-28 04:49:24.185: DEBUG/dalvikvm(6378): Trying to load lib libjavacore.so 0x0
07-28 04:49:24.185: DEBUG/dalvikvm(6378): Added shared lib libjavacore.so 0x0
07-28 04:49:24.195: DEBUG/dalvikvm(6378): Trying to load lib libnativehelper.so 0x0
07-28 04:49:24.195: DEBUG/dalvikvm(6378): Added shared lib libnativehelper.so 0x0
07-28 04:49:24.385: DEBUG/AndroidRuntime(6378): Calling main entry com.android.commands.pm.Pm
07-28 04:49:26.978: DEBUG/AndroidRuntime(6378): Shutting down VM
07-28 04:49:26.988: DEBUG/dalvikvm(6378): GC_CONCURRENT freed 157K, 21% free 627K/788K, paused 1ms+0ms, total 4ms
07-28 04:49:26.988: DEBUG/jdwp(6378): Got wake-up signal, bailing out of select
07-28 04:49:26.988: DEBUG/dalvikvm(6378): Debugger has detached; object registry had 1 entries
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): CheckJNI is OFF
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): setted country_code = USA
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): setted countryiso_code = US
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): setted sales_code = VZW
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): readGMSProperty: start
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): readGMSProperty: already setted!!
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): readGMSProperty: end
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): addProductProperty: start
07-28 04:49:27.468: DEBUG/dalvikvm(6420): Trying to load lib libjavacore.so 0x0
07-28 04:49:27.478: DEBUG/dalvikvm(6420): Added shared lib libjavacore.so 0x0
07-28 04:49:27.478: DEBUG/dalvikvm(6420): Trying to load lib libnativehelper.so 0x0
07-28 04:49:27.478: DEBUG/dalvikvm(6420): Added shared lib libnativehelper.so 0x0
07-28 04:49:27.649: DEBUG/AndroidRuntime(6420): Calling main entry com.android.commands.am.Am
07-28 04:49:27.659: DEBUG/dalvikvm(6420): Note: class Landroid/app/ActivityManagerNative; has 169 unimplemented (abstract) methods
07-28 04:49:27.719: DEBUG/AndroidRuntime(6420): Shutting down VM
07-28 04:49:27.729: DEBUG/dalvikvm(6420): GC_CONCURRENT freed 157K, 20% free 666K/828K, paused 0ms+1ms, total 3ms
07-28 04:49:27.729: DEBUG/jdwp(6420): Got wake-up signal, bailing out of select
07-28 04:49:27.729: DEBUG/dalvikvm(6420): Debugger has detached; object registry had 1 entries
I'm not exactly sure what is going on since Logcat is correctly targeting my physical device, it shows up on adb devices, and USB Debugging is on.
I've tried using Log.e but that had no effect on the output.
I even set android:debuggable="true" in AndroidManifest.xml.
Is there something I'm missing here? Why won't Logcat display my debug messages when running my app on my physical device?
EDIT: I tried the same app on a Android 4.2.2 emulator and Logcat works as expected with the emulator, but there's still the problem with Logcat through the USB device. Instead of the verbosity of a normal Logcat printout, the block I posted is the only thing I see on the Verbose log level.
Did you have enabled USB debugging for logcat ? (if your physical device is connected by USB cable). Go to "settings", then "applications", then "development", then check "USB debugging".
Then it should appear in DDMS. Just select it to debug/see logs.
You need to set logging (to the desired level) through the adb shell as follows:
./adb shell
for linux/mac/windows powershell or justadb shell
for windows cmd.Issue the following commands:
On some models you have to go to the developer options, and select "Allow all", on "Advanced logging".
The following screenshot is from my Meizu MX 4 Pro:
Today, I faced the same issue. Nothing worked for me as mentioned solutions. But what worked for me is in Android Studio Right side at the bottom as mentioned in the image. Select the option as mentioned in the image. After that everything was working as expected. Now posting my solution it may help others.
Hope that helps others
Maybe not an answer, but need to show pictures. Try to set a Filter for Your TAG like this:
and select verbose option:
does this help?
It might because of some phones disabled log to enhance performance.
For example, my phone HUAWEI P9 lite, i have to do the following steps to make
Log.d
works:ProjectMenu
pageBackground Settings
LOG Settings
AP Log
.LOG Settings
.[UPDATE]
Just now it happen again after I pull from git,
adb shell
shows this:I test with new project and it got log, only this old project has issue. I tried rebuild the app, re-enable the log steps above, and even reboot phone, but still no luck.
Then I uninstall the app (Or all relevant
productFlavors
apps) in phone and reinstall, the log was back.