问题
For some reason, I can't seem to output anything in Logcat for the watchface example that you can pull from Github's repo. I've enabled the development features in the watch emulator. I have the latest Android Studio. When I start a brand new project, I can output to Logcat without a hitch. What am I doing wrong?
回答1:
I know this is an old question, but in case somebody is still coming across this looking for an answer:
I assume you're talking about Googles Watchface example?
That example uses isLoggable
to write to the logfiles, for example:
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "onConnected: " + connectionHint);
}
As you can read in the documentation for Log.isLoggable, the isLoggable
function is basically just a method of customizing/optimizing your log messages, and returns false
by default.
If you want to enable logging on DEBUG level you can do this via command line with this shell command:
adb shell setprop log.tag.NameOfMyActivity DEBUG
Hope this helps.
来源:https://stackoverflow.com/questions/27825958/how-do-you-debug-androids-watchface