I just downloaded Android Studio for Linux from: http://developer.android.com/sdk/installing/studio.html
I'm wondering how to print to the console?
Neither System.out.print(...)
nor Log.e(...)
from android.util.Log
seem to work.
This question is related to
java
android
mobile
development-environment
android-studio
You can see the println()
statements in the Run
window of Android Studio.
See detailed answer with screenshot here.
Android has its own method of printing messages (called logs
) to the console, known as the LogCat
.
When you want to print something to the LogCat
, you use a Log
object, and specify the category of message.
The main options are:
Log.d
Log.e
Log.i
Log.v
Log.w
You print a message by using a Log
statement in your code, like the following example:
Log.d("myTag", "This is my message");
Within Android Studio, you can search for log messages labelled myTag
to easily find the message in the LogCat
. You can also choose to filter logs by category, such as "Debug" or "Warn".
If the other solutions don't work, you can always see the output in the Android Monitor.
Make sure to set your filter to Show only selected application or create a custom filter.
If your app is launched from device, not IDE, you can do later in menu: Run
- Attach Debugger to Android Process
.
This can be useful when debugging notifications on closed application.
I had solve the issue by revoking my USB debugging authorizations.
To Revoke,
Go to Device Settings > Enable Developer Options > Revoke USB debugging authorizations
Source: Stackoverflow.com