Why is logcat not showing anything? [duplicate] - android

This question already has answers here:
Why doesn't logcat show anything in my Android?
(29 answers)
Closed 7 years ago.
I am using Eclipse classic to develop my Android applications. But I am not able to see any messages in the LogCat. Till yesterday it was showing each and every message, but now it is not showing anything. I have written a lot of log statements to trace my program, but because of this I am not able to trace.
Where is the problem?

Try these first
Go to the device tab, click your device. and go back to the logcat
tab
You might have filter set.
You are probably viewing the wrong package.

I've got it solved by:
Closing the logcat window
Running the following in command prompt:
adb kill-server
adb start-server
Opening logcat again

Every now and then I experience that the logcat output in Eclipse stops showing any logs. It doesn't matter if I unplug and plug the device. It seems like the issue occurs if the logcat gets a ton of messages, and is unable to handle the amount.
The only thing working is restarting Eclipse or use DDMS directly (which also suffers from the same problem).

Go to Window - Preferences - Android - Logcat .
On that page
"Show logcat view if message priority is at least " select VERBOSE.

This happens when you don't close eclipse for a long duration, just close eclipse and reopen it, your problem should be solved.

Correct answer: it is/was a bug in Eclipse. All I did to trigger it was to rename one of the filter and pressing the Run button.
Restarting Eclipse fixes it.

In eclipse, go to: windows->preferences
Then go to Android->logcat and make sure you have the following setup:
1. double-click action: "go to problem (error line)
2. switch to: java
3. both checkboxes are checked
if your setup is fine, clean the project and restart eclipse
good luck!

Some times it does happen on a slower machine that eclipse waits for emulator HOME screen and after waiting too long it shows that the emulator is offline.
Secondly Make sure that you are looking in the correct filter or in all messages part.
Also you can do the following :
select the device and find your process (e.g. "com.android.myapp")
Look for its process id written to its left (eg. 17260)
Now go to logcat and add a new filter by witting a particular name and the specific Pid (say 17260)
Now select that filter and you'l be able to see your log messages
Good Luck!

I had the same issue, but gave up on eclipse logcat panel and switched to cygwin+adb:
make sure the app is running and launch cygwin
cd /cygdrive/c/android_sdk/sdk/platform-tools #go to where adb.exe is
[optional] ./adb logcat -c #clean the log, obviously don't do this if you want to see some old messages
./adb logcat #see all messages
or
./adb logcat | grep "whatever" #look only for whatever you want to look for

Go to Device from DDMS and open it.
Select your device from which device your application is running
Select your project which you run on this device

I had this issue for the last few days and tried everything above.
As it turned out, my problem was that all my log statements were in a class that was not being reached. I thought it had because of what was being displayed but that was not the case.
So in short, check with the following
Post log statements at the beginning of every method.

I too had the same problem , and I solved the issue by
-> restart the eclipse
-> go to ddms -> click on the emulator

I tried all the above solutions, but nothing did work. Then, I saw I had a button named "R", then something clicked in my mind, I renamed it to:
R1=(Button) findViewById(R.id.button1);
So maybe it was conflicting with R of Android and Java name of a button "R".
Hurray error got resolved.
Let us conclude with the following steps:
Check if u have any variable(button,textview) name which is “R”
Save your project, close Eclipse and then open it again.
Project --> clean
import android.R; remove this.
Correct answer: it is/was a bug in Eclipse. All I did to trigger it was to rename one of the filter and pressing the Run button. Restarting Eclipse fixes it.

You might have switched off LogCat by Mistake
Go to Preferences>Android
Click LogCat and make sure there is a check next to "Monitor logcat for messages from applications in workspace"
Then select the dropdown "Show logcat view if message priority is at least" and choose "VERBOSE" (or depending on how you tag your Logs, but VERBOSE will get all output)
Click "Apply" and you should start seeing your messages again

Make sure that you set
android:debuggable="true"
in your manifest file.

I was facing the same problem and the following steps resolved the issue:
Restart my Eclipse
Restart my Emulator
Select devices tab from DDMS perspective in Eclipse.

Check the device is not at fault. My device was set not to log, accidentally disabled it via boeffla kernel. After turning it back on logcat worked fine.

Go to windows->preference->android->logcat
select the option -
show logcat if message priority is atleat verbose.
It will show all the events of device and close all the perpestive and open logcat it will be working again.

On right top corner click on "Display Saved Filter View" or if "display saved filter view" is already open then just click on the red - icon to delete selected logcat filter.

Related

What can I do to prevent Android Studio from automatically clearing my log

I've got an activity that when it launches, it crashes but it leaves no trace of what went wrong in the console. I can see a very brief moment of red text before its cleared. The dropdown which shows the currently debugged app quickly switches from my app to "no debuggable applications" and back in the blink of an eye.
Is there a way to prevent this behavior?
You have to disable the ADB integration:
Tools -> Android -> Enable ADB integration
There should be no icon before this menu item.
Your LogCat now keeps the log output after your application closes or the application crashes.
Look at the Android Studio console and find the drop down list which states 'Show only selected application'. Change it to 'No Filters' to see all log output from the Android device. You'll have to navigate to find your crash, but your class names, etc. and log tags will all be there so it won't be too difficult.
You can store you log into a file. Go to your terminal and type adb logcat > logfile.txt
(If your have not done it before you will need to add the directory platform-tools of your sdk to your path. See this link http://www.troubleshooters.com/linux/prepostpath.htm)
I haven't found a a good solution to this behavior, but there are some alternative strategies for getting the logcat to display.
First, the logcat is actually available in two places in Android Studio. The first is the logcat tab in the debug pane, which is the one that gives me the most trouble. The second is the logcat tab in the Android pane, which usually works a little better. If there is nothing there either, typically setting the filter to "no filter" and log level to "error" will get me where I want to be.
Second, you can always run logcat from a command prompt. The output won't be as pretty or as readily filterable, but you can write it to a text file and search in there. I generally use adb logcat -v time > logcat.txtto include the timestamps and write the log to a text file.

Unable to set breakpoints in Android Studio

I am working on Ubuntu 14.04, AndroidStudio is 1.2.1.1. I am able to build the app, click on the "Debug" icon and launch the app. I can see logcat output and I can pause the app from the debugger. The one thing I cannot do is set a break point. I tried clearing the cache, restarting AS, right clicking in the file where I want to set the break point. None of these produce the desired effect. This is a well-hidden feature.
I also had this same issue in Android Studio, where I couldn't set breakpoints. This is what I was doing wrong: I was clicking on a line that didn't have any code in it, or a line that contained a comment. As soon as I clicked on a line in method/class, it allowed me to set the breakpoint.
There shouldn't be any problems setting break points if you follow the process outlined here
If you are running into some issues, here are a few steps to get you started:
- Use a Log.d() in your app and see if it outputs to the logs. If it doesn't then you know you are not in debug mode.
- Are you debugging on the device or the emulator? If the device, you need to enable development. I would suggest to select "wait for debugger" to make sure it's attached before you run the code.
This should be pretty straightforward. Let me know what you find out.
To add a line breakpoint, proceed as follows:
Locate the line of code where you want to pause execution, then either click the left gutter along that line of code or place the caret on the line and press Control+F8 (on Mac, Command+F8).
If your app is already running, you don't need to update it to add the breakpoint—just click Attach debugger to Android proccess . Otherwise, start debugging by clicking Debug .

Android Studio, logcat cleans after app closes

I'm having a problem with my logcat since update 1.2 Beta for Android Studio. When I run my app it logs everything like it normally did, then I get at the point where my app crashes with the app saying: unfortunately, Game has stopped.
After a few seconds android closes that message. When that happens my logcat also gets fully cleared meaning that I barely get anytime to read the error. I did found some info about a buffer, but it seems that Android Studio doesn't have the option to increase it besides the fact that I doubt that being the problem.
Something that may be useful is that after it clears and stuff the process changes to Android.process.core and the message I get in my logcat is:
04-13 10:28:13.394 12259-12265/android.process.acore D/dalvikvm﹕
Debugger has detached; object registry had 1 entries
Edit: I did read about breakpoints, so disabled focus application on breakpoints in Settings-build, execution, deployment-debugger but it didn't have any effect.
I had the same issue, but looks more like a feature than a bug:
In AndroidStudio, the default setting for the Logcat window seems to be "Show only selected Application" (top right corner of the Logcat window)... which is looking at the log of the selected process (your current launch by default). So when your app crashes during testing, that process is gone, so the filter clears the log.
Instead, select "Edit Filter Configuration..." and set up a filter for your app, eg:
FilterName: MyApp
PackageName: com.example.myapp (<< replace with your app's package name)
...and then select that filter for future runs. This should keep the log there for you, even after the app crashes.
Switch "Show only selected application" to "No filters". This way, you can see logcat output from a process even when that process isn't running.
The downside is that your logcat will be filled with more spam from other processes.
In case of crash see the Run tab at the bottom of IDE.
You can see the crash reason in this part (even in logcat clean case).
Note: If the above trick not works try to produce a crash and immediately disconnect the mobile cable (if you use the real device for the test). you can see the error before it cleaned.
Update: If also above trick not works, try to attach and detach phone and hopefully problem solved.
Update2: If again not work, try to Invalidate catches and Restart then start debugging again.
Update3: As The last way, try to remove the app and install it again then start debugging (if you do not lose that condition you want to test)
My App was crashing and restarting. I also had some problems on reading the logcat to know what was happening. I then noticed that in the drop down menu, next to the Device dropdown it had something like "com.mypackage.myapp ('some number')" and when my app crashed there was another option that said "com.mypackage.myapp ('some number') [DEAD]". If you select the "Dead" option, it will show you the logcat of the previous instance.
Might be very late to the party but I had the same problem and solved like this:
In logcat window, top right corner drop-down menu select Edit filter configuration, on the next menu, introduce Filter name and your Package name.
Done, for me it keeps logs visible after crashing.
In Android Studio 2+
Click Run
Click Edit Configurations
In the Run/Debug Configurations window select the Miscellaneous tab
Make sure the Clear log before launch checkbox is not checked
The filter clears the log once the app gets crashed. So select "Edit Filter Configuration" and create your own custom filter with filter name. This will save the log with informations even when the app is crahed.
I'm Working with Android Studio 4.0
enter image description here
Go to Edit Configuration of your app.
Go to Miscellaneous Tab
Uncheck the field Clear log before launch.
Press OK.
It'll work..
i have faced the same issue and this is the solution :-
1- Tools --> Android --> Enable ADB Integration.
and now you can see the logcat and the crashes as normal
It is 2018 and this can still happen. Close Android Studio and reopen.
7 years later ...
I still have same issue on AS ArcticFox and nothing helps.
But I have found one workaround.
make sure this is enabled:
Then you can see your logs regardless the app is alive or not or device is connected or not. Which is great!
Still, sometimes I get this problem although some solutions work here such as restarting android studio it takes time.
Here I found how to get error message without restarting the studio
Launch the app
Be on run tab before you make your reproduce crash
Click on the content of run tab as soon as crash occurs (if you don't click on content you will lose error report)
This bug seems to be fixed with the new release of Android Studio version 1.2.2
I ran into the same problem and none of the answers could help me, until I realized my app was causing an OutOfMemoryException. That's a probable root cause as well.

How do I pause the command window when launching an app?

When I launch an Android app via Ctrl+F11 on Eclipse, there are two black command windows (DOS-like) that appear briefly with some important messages in them. Obviously, I can't read what's in them in that brief moment.
Is there a way to pause/freeze them?
Update: #Mayra's answers below provided great tips but they did not solve the problem of pausing/freezing these windows. I know for sure that they contain information not in the Console and not in the logcat. So the question remains.
I'm not sure what windows you are referring to, but you shouldn't have to do anything like that.
All relevant information is displayed in either the Console or logcat tabs. You can open either via window -> show view.
You can also access logcat by running adb logcat from the command line.
Unless an answer that describes step-by-step how to pause the command window when launching an android app from Eclipse (to the emulator) comes along, the accepted answer is: This cannot be done.

Logcat not displaying my log calls

I'm a total noob at Android programming, and wanted to learn how to debug my apps. I can't seem to have my Log.i|d|v calls displayed in the LogCat.
Here's the code that I'm using. As you can see I have defined a LOG_TAG constant, but can't seem to find it in the LogCat. I have also imported android.util.Log AND I have made sure that in my AndroidManifest I have "debuggable" set to TRUE.
I have also checked http://developer.android.com/reference/android/util/Log.html w/o any luck resolving this issue.
What am I doing wrong? Am I even looking in the right place? I've tried using the DDMS and Debug perspective as well w/o any luck. Any help to this noob would be greatly appreciated. Thanks.
My environment:
Windows XP
IDE = Eclipse Version: 3.6.1, Build id: M20100909-0800
Emulator = having it point to android sdk 2.1 api 7
//very basic HELLO World code with a couple of Log.i calls
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class debugger extends Activity {
private static final String LOG_TAG = "debugger";
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
Log.i(LOG_TAG, "line 13");
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i(LOG_TAG, "CREATING NOW");
}
}
When using Eclipse, in the DDMS perspective, make sure the correct device (propably emulator-xxxx) is selected and highlighted. Only then will you get the logcat output in the logcat view.
Also, the Android plugin is a bit quircky, and sometimes only shows the last line in the logcat view. If this happens, try to clear the log. After that, you should get all the log entries again (works for me anyway).
If all else fails:
I did all the above things and couldn't figure out what was wrong,
Test with:
adb logcat
to figure out that my entries were infact in logcat, but twas adt's quirks.
Fix:
Restart eclipse
This was the only thing that fixed it.
I've had the same problem using Android Studio and managed to get around by selecting No Filters in the select box in the top right corner of LogCat. By doing this I started receiving everything Android logs in the background into LogCat including my missing Log calls.
Restart Eclipse and check log cat will be displayed.
I figured out I was automatically importing com.sileria.Log (from some library project) instead of android.util.Log, where the latter was the correct one. Check your imports as well.
I've noticed that Eclipse will sometimes throw an exception upon starting an Android app, then LogCat stops updating. I've corrected that by simply restarting Eclipse. I'm not sure if you've tried that and I know it's far from an optimal solution, but I suspect that the Eclipse plugin still has a few bugs to iron out.
Easiest way:
Check in your logcat window - TOP RIGHT corner PAUSE button || (Pause receiving new logcat messages)
Few clicks + eventually restart eclipse (usually works in my case)
I needed to restart the adb service with the command adb usb
Prior to this I was getting all logging and able to debug, but wasn't getting my own log lines (yes, I was getting system logging associated with my application).
There are a number of reasons why you might not see logs, most of which are listed below. Here are some steps to check most reasons:
Make sure you don't have 'android:debuggable="false"' in your
AndroidManifest.xml
Make sure your logcat isn't paused and make sure you are scrolled to the bottom
Your filters should either be 'no filters' or your current app
You have the correct device selected in your logcat devices list
If you're not getting any messages, try restarting adb. You can do that from Android Studio by clicking on the 'restart' icon, it's right after the print icon for logcat and it looks like a green curved arrow coming out of a box. If you don't see it, mouse over the '>>' that continues the icon menu when the logcat is too small.
QUICK FIX.
Just restart the eclipse
Works Perfect.
On Android Studio:
Click on the green arrow pointing to the right to restart the logging; if it is not visible, click on the >> icons to locate it.
I'm a newb as well to Android-Eclipse. Here's what it took for me to get LogCat messages to display in Eclipse:
1: add this to the class in which the logcat message is called:
private static final String TAG = "MyActivity"; (per the documentation here)
2: add this Log.i(TAG, "inLayout - finished"); when you where you want to display a message
If the above doesn't work, then shutdonw Eclipse and restart it and rerun your project.
It should then work.
There is one more thing to watch for:
On the top right side of the logcat there is a dropdown table for filtering messages by type. Make sure it's on the level you are looking for (if it will be on the assert level, it will likely leave your logcat empty).
Please go to Task Manager and kill the adb.exe process. Restart your eclipse again.
or
try adb kill-server and then adb start-server command.
Probably it's not be correct, and a little bit longer, but I solved this problem (Android Studio) by using this:
System.out.println("Some text here");
Like this:
try {
...code here...
} catch(Exception e) {
System.out.println("Error desc: " + e.getMessage());
}
I spent several hours on such case. I saw only touch keys logs. Nothing more. Problem was... smarthphone. After restarting was OK. Disconnecting cable caused problem returned. Had to restart it again.
Looks like the Android USB communication is not well designed.
Using the SDK 4.0.3 you have to explicitly select it on debug configurations > project > target or else it will never show using Eclipse Indigo (3.7). Of course an eclipse restart ensues.
I had a problem seeing simple log output in logcat as well. My problem was solved when I installed the latest JDK. I just setup a new development machine and only had the JRE installed and instaling the JDK worked for me.
None of the other answers worked for me, but this did:
I removed my project from my workspace, then deleted anything that started with a dot (.settings, .project, etc.) from the project folder. Then I re-imported the projected. I'm missing some settings and breakpoints but at least it works.
I had been experiencing this problem and nothing seemed to work until I moved the log call into a handler. Now it works every time, no matter where you are at.
I made the mistake of typing in a search term in the logcat search box.
I forgot to delete it and hence couldn't see the new logs. Since they didn't match my search term and weren't displayed.
In my case, I had to remove this line:
<application
android:debuggable="false" <!-- Remove this line -->
..../>
From Application tag in my Manifest file.
Best solution for me was restart adb server (while I have Enabled ADB integration in Android studio - Tools - Android - checked). To do this quickly I created adbr.bat file inside android-sdk\platform-tools directory (where is adb.exe located) with this inside:
adb kill-server
adb start-server
Because I have this folder in PATH system variable, always when I need restart adb from Android studio, I can write only into terminal adbr and it is done.
Another option to do this is through Android Device Monitor in Devices tab - Menu after click on small arrow right - Reset adb.
For eclipse:
1) Go to ddms perspective.
2) Make sure that correct device is selected.
3) If already selected and not displaying logs, then restart ABD.
* Hope this will solve.
I restarted the ADB service as well with "adb usb" and fixes the problem for me. In fact, only one of my activities didn't log anymore. All the others did log stuff. After restart adb everything works like a charm again. For the other people who're searching for another solution: adb kill-server, adb start-server in CLI will often fix your problem aswell.
make your app force close once
this will start LogCat again ...
use this for force close :D
setContentView(BIND_AUTO_CREATE);
some times the problem is not from pc on the other hand IDE,ADB etc, but it arises from your device that doesn't send logs to ADB so if you tried all the ways mentioned before and still your logcat is empty try to restart your device and try again.I tried all the ways mentioned above and neither of them worked but after a restart on my phone logcat worked like magic
I have this problems and fixed, String TAG without space:
"my tag" // noting show
"my_tag" // is ok
In my case I just had to add a name to the String. In first instance I just had a space in between the brackets
private static final String TAG = " ";
but after adding a name it worked perfectly.
private static final String TAG = "oncreate";
After upgrade to Android 3.6.1, I have experienced this issue multiple times.
The only thing that works in my case is RESTARTING THE DEVICE.

Categories

Resources