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

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.

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.

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.

Why is logcat not showing anything? [duplicate]

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.

How to get debugging statements for Android in Eclipse

I've read the lame documentation, and checked other answers. I'd like my Android app to print some debug statements in the logcat window of Eclispe. If I use the isLoggable method on the various types of debug levels on the Log class, I find that WARN and INFO are returning true.
Log.w, and Log.i do not produce any output. Does anyone know which gotchas I've missed?
And just to vent, why should this be hard? I've published apps for iphone and bberry and while appreciate the use of java, the platform is reeking of too many "genuiuses" being involved. I suppose Activities and Intents are very flexible, but why? I just want to put up some screens, take some input and show some results. The bberry pushscreen and popscreen is a lot less pretentious.
Thanks,
Gerry
The problem with debugging with Android in Eclipse is that from Eclipse's point of view, you're debugging the emulator and not your specific app. The emulator isn't crashing, so there aren't any logs to show. What you need to use is LogCat, Android's debugging plug-in. See this answer for details on how to bring that up.
It is not clear to me what the problem is. I use "Log.d(TAG, "special message");" all the time in Eclipse in Android code running in the emulator. Since you say "Log.w" gives no output, I assume you already know about the need to import android.util.Log. Otherwise you would not have got even that far.
The only other thing I can think of is for you to check your Eclipse Preferences under Window>Preferences>Android>DDMS (DDMS is needed for Logcat). Make sure the timeout is reasonable (mine defaulted to 5000mS). Make sure the base local debugger port is open, too.

Android - Having a hard time debuging Eclipse

I am a little bit new to developing for Android using Eclipse (Coming from a .NET/Visual Studio background).
My biggest problem in developing Android app is "debugging" them. Every time the emulator throws an error, there is no message, no explanation of what caused the error. I basically have to keep doing trial/error until something works.
My question is: Is there a better way to analyze the error messages that emulator shows (basically some stack trace about Dalvik)!
Also, is it possible in Eclipse [when debugging] to move the debugging cursor backwards to re-evaluate a variable or "skip" some lines of code?
Use LogCat view to see error/debugging messages. Regular console is of very limited help. Window->Show View->Other->Android->LogCat There on the top you will see some round buttons that basically can filter log from V (verbose) to E (error). You can't copy/paste from theLogCat window but you can save selected output to text file
Regarding the error messages (I'm assuming these are the messages that show up in LogCat): I've found that analysing the error messages and working your way up the list until you reach code that is yours is the most effective way to work. Frequently (for me at least) the emulator will crash and break somewhere in the OS code (which you probably don't have the source for) but you can follow the LogCat messages back to your code and start to see where the problem is. The crash may appear to happen in the OS code, but the original cause is typically you passing something wrong to the OS.
Regarding going backwards in code: nope, at least not with the my Eclipse Ganymede install
Regarding skipping code: When your in debug mode under the Run menu you can select "Step Over" (skips going into a method) , "Step Return" to exit a method and "Run to Line" in addition to setting Breakpoints by right clicking. This causes the code to run, but you aren't single stepping through it. Otherwise the only way to "skip" lines of code is to comment it out. I believe you can also change the value of variables in the debugger, but I've never tried personally. This may give you the desired effect.
Try closing all unrelated project, switch off eclipse and then do a clean and build for the project in picture.

Categories

Resources