i never see the logcat output in android emulator? - android

i want see the console output so i use the Logcat but the logcat is not display any output messages. i also restart eclipse.also click on devices log in android DDMS.i also do the Reset All perspective of DDMS.but i can`t success.

Select the device/emulator in DDMS when its in online mode.And there is '+' sign(green coloured) in left panel under "Saved Filters" of the LogCat.Click it and add your whole package name in "Filter Name" and "by Application Name".Try this.

Make sure that in your Logcat the buttons to the top right aren't selected. One of them blocks the Logcat to display new logs. Hope that helps.

Related

Android Monitor logcat not displaying any messages - studio version 2.2.1

I am new to app development and have come across an issue my course hasn't yet covered but requires.
I have created a simple app that generates a log entry using Log.i after clicking a button - see screenshot below.
link to screenshot
As you may well see, no logs have been generated at all for the running emulator. This happened on an earlier app and after searching for an answer, found that going to the terminal and finding the appropriate directory, I could restart the adb using the 'kill-server' and 'start-server' commands. As this didn't work, I found the file in windows explorer and double clicked the adb.exe file. This seemed to fix the problem.
Having started another project (the one linked in the screenshot), the same problem has arisen but the same steps do not correct the issue and as such have nothing being generated in the logcat.
*beneath the emulator you see, I have nothing in the search box, the logcat is set to verbose and regex(?) is ticked.
Any help with this would be greatly appreciated as i'm reluctant to proceed with the course material before sorting out this issue.
Thanks.
some additional information I have found in the 'AVD' section of the 'Run' Window :
libpng warnings
adb successful start?
EDIT - requested code
EDIT 2 - It's a bit of a bodge but it seems the adb operator command 'logcat' used in the Terminal, turns the terminal into the logcat i.e. c:..\sdk\adb logcat' - all my missing logs, including the ones generated by the buttonClicked function appear in the terminal and new logs also appear there.
Terminal as logcat
Thank you for your responses but maybe someone knows a way to fix the logcat itself, i'd appreciate the answer. Thanks again.
I have managed to resolve the issue by closing all related software, rebooting my laptop and running the adb.exe file in the ..\android\sdk\platform-tools\ directory before launching the android studio.
Hope this helps if anyone else has the same issue.
Stitches S, I think you are not calling the buttonclicked method anywhere as I haven't seen it calling in the screenshot. But if you are calling it somewhere else then try log.d() to print that. It always works for me.
if you want to see log on button click set the buttonClick method inside the oncreate(), may be its doing nothing that's why not showing any log
this code is working in my case:
public class About_us extends AppCompatActivity {
TextView header, address;
private String Info="Info";
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contact);
header=findViewById(R.id.head);
address= findViewById(R.id.tv_address);
}
public void buttonClick(View view){
Log.d( Info,"button is clickd" );
}
}
and this is my xml view
<TextView android:id="#+id/head"
android:onClick="buttonClick"
android:layout_width="match_parent"
android:background="#color/third"
android:text="#string/app_name"
android:gravity="center"
android:textSize="20sp"
android:textColor="#color/first"
android:layout_height="30dp"/>

I cannot see my logs in android studio

Random rn = new Random();
Log.e("" , Integer.toString(rn.nextInt() % 20));
But in section logcat I see something else log
P.S. I just started learning , and don`t full understand how work in IDE
Could you post here what you see in logcat?
How are you running the app?
(I do not not have enough rep to comment on question).
You should see something like this:
04-22 18:25:32.446 1131-1131/com.your.app E/randīš• 19
When running the app, this should appear in red colour. Also make sure the search box (right of "log level" on picture) is empty and the text field next to it has "No filters".

Not able to input in android application through keyboard?

I want to enter username and password in android application through key board but i am not able to do that? please help me out? and give proper solution.
This is case for all android application.
Click on the Windows->AVD Manager->
on nice window will appear for manage ur virtual device after that click on the "Edit"
In that u can show "Hardware :" ..... in that click on the "New" button...
under the title of "Property :" Select the "Key Board Support"... and Press "Ok"...
after this u can see that in the "Hardware :" grid... in that select the "Yes".. for key board support....
default keyboard support has been removed after ADT 20 update.
you can enable it by yourself by editing the AVD
please check the following URL
https://android.stackexchange.com/questions/23333/how-can-i-use-my-pcs-keyboard-on-the-android-emulator

Android - Trace

How can I trace the output from eclipse and the android simulator. I am used to doing it in Flash and actionscript.
In AS3 it would be:
trace('my trace statement');
You have a few options. One is the java.util.logging.ConsoleHandler class: http://developer.android.com/reference/java/util/logging/ConsoleHandler.html
ConsoleHandler console = new ConsoleHandler();
console.publish(new LogRecord(Level.INFO, "Hello logging!"));
Another option is using the Log class:
http://developer.android.com/reference/android/util/Log.html
Log.v("MyIdentifier", "Hello logging!");
In android use the Log class to provide this. Simply pick a level you want "debug, warning, info" and then use the function. ie `Log.d("tag","message");
Then this message will appear in the LogCat Eclipse window

Android Debugging, how?

Ok so I've finally cobbled enough working parts into my app that its just plain old refusing to do anything now. I understand how to use logcat, but that is about it.
The main problem at the moment is that I get the error
Activity Idle Timeout for HistoryRecord then my package
I need to learn how to do better debugging. Plus if anyone can suggest things I should do for this error please let me know.
I think its something to do with the interactions with the database.
Cheers
EDIT:
What IDE are you using, if any?
Eclipse with Android tool has
moderately good debugging facilities;
set a breakpoint and debug away.
I am using Eclipse
And I know of breakpoints, but not their real use. Where would I set them for this error?
I am used to PHP where errors tell you a specific line to look at is there a way to do this in Eclipse?
In Eclipse if you right click in the margin next to your code - easy place to start is probably in your onCreate method - you can choose to Toggle Breakpoint. This will set a breakpoint at that location.
Now, in Eclipse choose Run->Debug As->Android Application.
This will run your app in the emulator and your app with stop running at your breakpoint. At this point you can step thru your code line by line using F6 I believe.
Once you've hit the breakpoint and your code is paused, use a guide like this http://www.ibm.com/developerworks/library/os-ecbug/ which will highlight all the different things you can do at that point.
Max... If you can wrap the offending line of code in try catch you can log the exception or set a breakpoint at the exception. So for the code below that will throw an exception:
String test= null;
try {
test.length();
}
catch (Exception e) {
Log.d(TAG,"test",e);
}
LogCat will display test,java.lang.NullPointerException blah, blah, blah
OR you can set a breakpoint at the Log.d line and if hit in DEBUG mode the app will pause and the variable window in the DEBUG view will show:
this:MyApp e:NullPointerException
BUT it does not sound like your app is throwing an exception, rather it is timing out on a database call. I would stub out the call to the database and see if the timeout goes away. Then slowly add back code until it times out.
JAL

Categories

Resources