DDMS Not showing my logs - android

I'm having an issue with DDMS.
System logs are appearing fine, but my own logs aren't showing up.
I'm trying to view the logs in ddms.exe.
I've tried restarting adb, stop/start adb, restart ddms, restart emulator, recreate avd.
Nothing has had an effect. I've tested this with two different apps.
Any ideas?
EDIT same issue in logcat.
No filters selected
I've restarted the computer

As i remember you have to make you app debuggable ("android:debuggable=true") in your manifest file. Or you can find your app in DDMS but can't get access for your own logs?

can you try the command:
> adb logcat -s "TAG"
on a terminal/cmd line ?
here "TAG" is the name of the tag which you are giving in your Log

I failed to mention that i'm using a tool called Kony. It is a "write once deploy everywhere" mobile development environment.
When the app is being compiled in release mode (which I was unaware of) all print statements are removed.
Had this not been the case, some or all of the previous suggestions would have worked, i'm sure.

Adding to above.
It is true that the value we are trying to print will not be logged to the console but it is not strictly removal of print statements. Kony.print get executed .
This observation can be checked by building in release mode and trying to print and undefined value, you will get type error thrown.

Related

LogCat won't show my logs

I've searched for similar problems, but I didn't find anything useful - I'm working with eclipse, and I can't see my Logs.
The device is connected properly, the app runs and does what it's supposed to do, but I get no logs from it.
I get other logs messages from the device, not the ones that I print, e.g. Log.d("SMS", "hello"). On the other hand, if I use the statement System.out.println("hello"), I do see it, tagged as System.out.
I've tried to disconnect and reconnect the device, restart it, close and open eclipse, choose the device from Device window. It happens both with a 'real' device and an emulator. I've also tried to remove the filtering, but nothing helps - I still don't get the logs.
Okay, I've found the problem -
Apprently there are some illegal tags, and I've used one of them.
My app is spam SMS blocker, and I've used the tag SMS. If I change it to another tag (like SMSBlocker) it suddenly appears in the LogCat.
Check if your project is using proguard.
Basically proguard will remove all the debug logs and optimize your code while creating apk.
Try adding proguard.enabled=false in your project.properties
I think you should use TAG.
When you log from your android app, the first parameter is a TAG string. So if you set it up to a unique string (like your app name) then you can later filter by it in Eclipse.
Example : Log.e(TAG, "state error");

Android application lacking debug information in Android Studio

I'm trying to debug an application that I'm writing using Android Studio but I can't seem to get any useful debugging information out of Android Studio's "Debug" view. I'm launching my application with the bug-looking "Debug" icon but the "Debug" view doesn't have anything useful (no stack frames from my application, for example):
Even if my application crashes I don't get any useful information. As I recall, the ADT plugin would automatically drop you on the line that caused the crash.
Do I need to do anything else to make my application "debuggable" in Android Studio? I've also tried forcing android:debuggable="true" in my AndroidManifest.xml but to no avail. Android Studio does seem to be attaching to the running process (the app shows the "attaching to debugger" message for a few seconds when it first launches).
There are some things to check:
If your app-debugger is working and stopping on normal breakpoints, maybe you have to set an exception-breakpoint:
Open Debugger
Press "View breakpoints"
Usually, there should be a breakpoint called "Any exception" with checkboxes on "Caught exception" and "Unchaught exception". If not, add an exception breakpoint yourself and specify the type(s) of exceptions you want the debugger to stop on (you can use wildcards in the exception-classnames, e.g. *Exception).
If your app-debugger is not working, check the following options:
Check if you have enabled USB-Debugging in the developer options of your device
Check if you have authorized the computer as a development machine in the developer options of the device (if unsure, clear the authorization-list from the developer options page and reconnect the device)
Check if your development machine has only one adb-server-process running in the background (if more, kill all of them with a process mananger and restart with "adb start-server")
Add "debuggable true" to your debug-buildType in build.gradle:
buildTypes {
debug {
debuggable true
}
...
}
If your app-debugger is still not working, restart your computer and re-install adb-drivers for your device. Make sure there are no conflicting drivers active with more than one connected device (maybe connecting only one at a time).
Note: even if you got exception breakpoints working, they might not be useful at all, depending on the type of the crash. Most of the times, you will get the debugger stopping in the Zygote-exception handler where you don't get much useful information or stacktrace.
In such cases, it is the easiest to just let the debugger resume or reproduce the crash without a debugger, and check the logcat-output for a stacktrace in the ERROR-loglevel of your app's logcat-output. Those stacktraces should have clickable line-infos thus enabling you to set a normal breakpoint on a relevant line of code in your app's source code to analyze the problem.
After updating Android studio this problem went away. Not sure what the issue was.

LogCat is not showing null pointer exception

My LogCat is often not showing null pointer exceptions..
Sample:
ProgressDialog pd;
ps.show();
Application stops (do not reacts for any action), but there is no information about any reason in logcat.
Another sample is with database - if there is no DB and I'm making actions on it, the same happens.
I tried (that action with DB) on my colleague's phone and there was normal error. I have all needed programmer options in my phone turned on.
Maybe someone know , why it is so? It was not burdensome, when I had small app, but now when it's bigger, it can be really frustrating.
I get this with android studio too...
Close android studio, restart ADB, and generally it starts working for me.
If that does not work then put a breakpoint at the line .show(); ... Then open up the logcat and then skip over the breakpoint. It then shows, I have similar issues.
(Windows 7 64 bit - Android Studio 0.82)
I dont like the IDE logcat option honestly.
The SDK comes with an adb binary, use the logcat option from there via
adb logcat or my personal favorite built in alias, adb lolcat
This will give you the log information for EVERYTHING happening on the device, and can be useful tracking down issues caused by device state.
For example, you can see network changes in the logcat, and if your app crashes on network call you wouldnt have any idea why if you just used the logcat output from your app.
In my case I was using: Thread.setDefaultUncaughtExceptionHandler in my application file. If that is not turned off during debugging you won't see any exception output. ( Just make sure to turn it back on again when you release so you can still handle your issues ).

Why are Log.d() messages showing on device when they shouldn't?

Android docs indicate:
The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.
But try to do a Log.d() and you'll find it's actually still recording to Logcat on a real device.
Does anyone know why? Or how to disable it?
Thank you!
What you are seeing is expected behaviour. Log.d will always be logged and visible if you use logcat and connect the device. Hence if you dont want debug logs in production app , turn it off. Infact android sdk suggests you do that. This SO answer might help you as well. Should I comment my log calls when creating my final package?
Andriod sdk says
Turn off logging and debugging
Make sure you deactivate logging and disable the debugging option
before you build your application for release. You can deactivate
logging by removing calls to Log methods in your source files. You can
disable debugging by removing the android:debuggable attribute from
the tag in your manifest file, or by setting the
android:debuggable attribute to false in your manifest file. Also,
remove any log files or static test files that were created in your
project.
Also, you should remove all Debug tracing calls that you added to your
code, such as startMethodTracing() and stopMethodTracing() method
calls.
Source
You should encapsulate logging in your own class and enable/disable special types of logs when you need.
if verbose is compiled in dvelopment, it would be funny if debug logs not. So signe your app and give it a try, i think the debug messages are missing then.
When you plug your device it activates the debug mode. I don't think it's doing the same if the app run with the device unplugged, though you can not check that...

How to react on a force close?

I'm developing a first app for android, and I sometimes get a message "this application stopped unexpectedly" and a "close" button.
How can I find out what's wrong? When the phone is connected to the computer, it would show in the Logcat of Eclipse, but my phone is not always connected to my computer. How do you handle that? How do you handle the error reporting in your app when it's not in debuggable status?
How can I configure my app to restart in such an occasion? I have an other app (not developped by me) which sometimes shows the message that it restarted after memory low (or something like that). I'd like to restart my app too when, for whatever reason, it crashed.
Anybody?
I am not sure about the second question but for the first part you can run adb logcat in background. for that just go to the folder location where adb.exe esixts, in command prompt and just type
adb logcat > /data/log.txt &
it will run in the background and store the logs in log.txt file. When you are done with your force close. just type following command
adb pull /data/log.txt .
it will extract the logs, and will put in the current directory location, you can open it using any text editor.
If your device is not connected to a computer, you can see the logcat output using the following app: aLogcat
Also, I'm not sure that restarting an app that has just crashed is a good idea. This could lead to an infinite loop of crashing/restarting.

Categories

Resources