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.
Related
Everything works in Debug Mode but Crashes in Release Mode. What required permissions are available in Debug Mode that are not turned on in Release mode?
EDIT
When I set Linking to None, I get past the first screen to my Login screen. However, when I added the Release permission Internet, the first time it tries to read a remote Entity Framework Core Table it crashes.
EDIT 2
In Release Mode, if I check Use Shared Runtime, the app runs fine.
EDIT 3
I have turned on Debugging while in Release mode Temporarily. The Following line throws a System.TypeInitializationException only in Release Mode:
if (_context.bma_users.Any(p => p.username == _name.Text) && _name.Text != string.Empty)
IF YOU JUST WANT TO SEE THE CRASH LOG:
Assuming you have Android Studio and no crash report service implemented (Firebase, Crashlytics, etc...)
You might want to see the crash log print first:
Open the Logcat in Android Studio.
Change Log Level to Error.
Make sure USB debugging is enabled on your device.
Connect your device to the computer.
Make the app crash and see what it prints.
If you can't reproduce:
Next time it crashes, connect the device and do the same as above. Usually the log history will be available to view, scroll until you find the crash :)
Look for FATAL EXCEPTION
Keep in mind - using the Logcat search bar can clear the log history, in most cases you can reconnect your device to view it again.
You already assume "permission", not sure why...
The first thing I disable when I have something crashing only in release mode is minify (aka ProGuard). So disable the obfuscation, build again and try to see if you still get crashes. If not, reenable proguard one line at a time to pinpoint the cause.
The answer was to set Additional supported encodings to West in the Android Options screen under Project Properties. It doesn't seem related but I was trying every possible combination and this finally worked.
You can just set debuggable: true for your release build type.
Don't forget to remove this property once you're done with debugging.
Go to the properties of the android section and then into the Android options tab.
Make sure that the "Use Shared Runtime" and "Use Fast Deployment" boxes are unticked in your release configuration
You can use any of the crashlytics tools like Firebase Analytics, Fabric, Splunk Mint to get the exact crash log
Please check crashlytics they mention exact line number where your app was crashing. You can see what error is showing, then you can fix.
I have a problem debugging the app in Android Studio 1.4.
A typical debug aspect is when, debugging on a physical device, I purposedly switch to other
apps and then I come back to my app to check if the current Activity has some
"null" variables that prevent activity from properly recharging.
I usually set some breakpoint at the beginning of the (onResume) method.
The problem is: when I run the app the first time, the breakpoint is normally taken.
When I switch to other apps and then return to the debugging app,
Android Studio doesn't catch the breakpoint, so I cannot debug what's wrong.
The same thing seemed to work properly in Eclipse.
Do you have any idea how to solve this? Thanks.
if your process is killed then the debugger is no longer attached.
You can attach a new debugger at any point
do this just after you finish using the last app and before you open your app
It will give you a list of processes and you have to select which process to attach the debugger to.
Usually the process name includes a prefix of your package name.
https://blog.pivotal.io/labs/labs/fast-android-debugging-with-intellij
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 ).
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.
All of a sudden I am not able to debug anything that i am doing in a service even though i put breakpoints all over. but logging shows that all the lines are getting executed. Can someone tell me what could be causing this issue. I am using eclipse and i have set to "Build automatically".
Do you have an Activity which is launched at the beginning of your application?
If not you have to manually activate the debug on your process by using the DDMS tool in Eclipse.
In DDMS -> Devices, check your process (the line contains the package name of your app), select it and then click on the debug button. A debug icon will appear near your process, then you should be able to use breakpoints in your Service.
If you are using a Runnable try placing this in the run() method:
android.os.Debug.waitForDebugger();