I am not using Eclipse or Android Studio, I am just compiling my code myself and installing with adb.
If an uncaught exception or error occurs, it prints the the line number of the code that triggered it, but not the message.
If I call Log.d or Log.i, etc. , nothing happens. If I catch an exception and call e.printStackTrace() or System.err.println(), nothing happens.
What could be the issue?
Update: By the way, I am accessing logcat via the Android Device Monitor.
Update: It works fine using adb logcat. I just need it to work from Android Device Monitor now.
Make sure you don't have any filter set.If you just use the following command you should be able to see all the logs.
adb logcat
if you want to see only logs with particular tag:
adb logcat -s "TAG"
Also make sure when you building the apk,you don't have any code that is disabling the logs-because its a release binary.
If you are viewing through IDE logcat view remove the filter.It must be there left hand side corner.If the filter level is error,you need to make it verbose.
I think your log level is too high for Log.i and Log.d (for example, if your log level is 'error' you only get error messages)
So set your log level to verbose to display all logs.
You can find the log level indicator in the top right of your Android tab in Android studio
Related
I am getting an endless stream of
E/IMASDK: Received monitor message: getViewability for invalid session id:
and it's making it impossible to see any other log statement in my LogCat. Does anyone know how to mute such a specific nuisance?
On the command line you can run something like
adb logcat IMASDK:S
to see log output but with IMASDK messages silenced. Android Studio also has support for filtering log messages. You can find it if you poke around in the UI a bit.
Im reading this chapter, so I'm just trying to connect to a website, but I'm getting an exception after calling connect(). The problem is that I don't know how to see what is the problem, since I want to solve it by myself debugging. Here below are pictures. Where can I find the error message to know why it can not connect?
In the given snapshots you have opened the debugging tab. Select the Android Monitor tab from the bottom which shows all logs. Upon opening the android tab you will see a dropdown with options verbose, error, info etc. Select info to see the error logs. Also in the debugging mode, once you reach the e.printStackTrace() line, the debugger will show you the value of e which will contain the error information.
In the Android app I'm currently working on I have all my try/catches to print out a stack trace but when using a physical android device via USB these errors do not seem to get printed. Further more, when I attempt to create a debug log on the device, it never shows up. My assumption is that I have to start relying on Log.d and print everything to the logcat. Is this correct?
Edit: I should also mention that these stack traces appear when using an emulator as well.
Also, I have noticed when debugging on a physical device when I hit break points it locks the application but it does not allow me to continue with debugging, a.k.a pass over the break point. Is this an error or simply how it preforms? Break points work fine on the genymotion emulator.
You are doing something in wrong way, be sure not to debug and look for logs at the same time and be sure you are using right filter at loging.
And at last be sure that you turn on debug mode on at your release version of app(or what version you are using at device).
For the logs, you should have to check is the log is enable, by using the following steps in eclipse:
* Go in Windows -> Preferences.
* After that, select Android -> LogCat.
* And set the option "Show logcat view if message priority is atleast:" to "VERBOSE".
I am using a Samsung Galaxy S3 device for development and my app is using the camera.
In the logcat, there is an output made by the native system with the tag Camera-JNI that is written to logcat like 20 times per second, causing the logcat to clean the oldest entries very fast.
Is it possible to disable logs from already installed apps or system logs to prevent this? Filters doesn't work, as the logcat is still filled and lines are still being clared.
Thank you.
EDIT
The documentation says this:
You can change the default level by setting a system property: setprop log.tag.<YOUR_LOG_TAG> <LEVEL>. You can also create a local.prop file that with the following in it:
log.tag.<YOUR_LOG_TAG>=<LEVEL> and place that in /data/local.prop.
EDIT 2
I already did this (rooting the device, pushing the local.prop file to /data and rebooting) but the tag is still appearing
I can see the following by examining the android source code (2.3.x):
Executing
shell setprop log.tag.XYZ
will not work here (frameworks/base/core/jni/android_hardware_Camera.cpp), as logging is being done using the LOGV() macro. This method of logging does not use properties to detect if some component wishes to disable logging. That is as far as I am able to trace the calls trough the android code.
So using setprop(...) will not work for disabling logging from an android system component but it should work when the logs come from user apps etc. written in Java which use base/core/java/android/util/Log.java and frameworks/base/core/jni/android_util_Log.cpp to log. My guess is that android_util_Log_isLoggable() is what is being used to filter.
IMHO I see no other alternative than building from source for your device and disabling the LOGV macros in the camera code you are using.
You can try something like adb shell setprop log.tag.Camera-JNI ERROR. If it doesn't work simply filter the log or dump it to a file and use grep to find the lines you are interested or filter out the camera with grep -v Camera-JNI.
If you want to see specific tags use:
logcat -s YourTag:* SecondTag:* ThirdTag:* ...
You can also use adb logcat
Just specify <TAG>:* as many times as you want to filter the tags you need.
Example: adb logcat -s AndroidRuntime:* MyApp:* filters AndroidRuntime and MyApp tags. So you see all uncaught exceptions (crashes) and also all logs of your application.
The app works fine in the emulator, but after installation on a phone, it crashes every time on launch, and logcat shows no errors.
What am I supposed to do when something like this happens?
My Suggestion for easier resolution of your problem :
Run the app from the eclipse in debug mode on the Phone . It will make it run on debug mode. You will most likely get more debug output.
Turn on ADB in the phone.
Connect the Phone to the PC
Run as "Debug Configuration" from eclipse.
It should run from your phone and Eclipse will ask for your choice for first time before running that.
Turning the Debug Mode on ( Note : This isn't the 'ADB connection' we are referring to ) , It will enable further logging of the application and doesn't do garbage collection normally.
( You will notice a 'Waiting for debug connection' dialogue , if the applications are forced to work in debug mode ).
For e.g :It makes the Async threads keep running and doesn't stop running. Crude and irrelevant for your case . But just as an example.
So , Since the Applications in the phone are forced to run in debug mode , it will get the logcat with detailed errors down to the specific threads.
However, the debug mode is better used when it's used in conjunction with "Debug As" run configuration from Eclipse. And keep in mind that it will automatically turn on that debug application mode ( And there by the dialog box also) , the logcat will show you more details and plus it will break-point at the errors which occur ,in their sequence of occurence.
Regarding what Ares told,
When you want to do the debugging of a process directly,
You can go to the DDMS panel in Eclipse,
On the right side tab menu Devices ,
Select the process you want to debug . and click on the green symbol ( Says, Start Debugging process )
It will automatically go to the source when it breaks if you have the source code in that eclipse work-space.
Additional hint:
On huawei phones, logcat doesn't show debug messages and excpetions, if the phone is in default system settings.
In order to enable logcat full logs on Huawei phones, you must do the following:
Open the factory settings menu by dialing *#*#2846579#*#*
Navigate to Project Menu / Background Setting / Log setting
On older phones: define the log availability (log switch) and level (log level setting).
On never phones: tick AP Log (which seems to enable app logging in general) and CP Log (seems to enable debug logging)
Close the menu with your backbutton (no restart needed)
Source: https://stackoverflow.com/a/18395092/1075072
Install a tool like AndroidSystemInfo that can show you the logfile on the phone - even when you are away from the host computer.
It is pretty unusual that Android leaves no trace whatsoever.
Does your app perhaps require features that the phone does not have (e.g. a camera or gps or nfc)?
In Eclipse you should go to DDMS, then click on device's name or android.os in Devices panel. And turn your device in debug mode.
Put your own logs to track what block of code cause crashe, or just debug it.
You can reset adb (In Devices -> View menu -> Reset adb)
Click on the selected online device/emulator to show the logcat
Disconnect the cable and again connect it. (Or restart the emulator)
Restart Eclipse
I restarted my emulator and cleaned my build. This got rid of both the non-logging and the spurious crash I was having