According to this and this, it should be easy to have Android Studio break on an uncaught exception. However, whatever I try, I seem not to get it working.
I set the "Class Filter" on my Activity, but the app just crashes on an uncaught exception, no breakpoint triggered.
Are you sure that the exception being raised is from the class that you've specified in the class filter?
Try configuring to break on all exceptions without the class filter enabled to validate that it's actually the specified class raising the exception: https://stackoverflow.com/a/28862538/3063884
I was unable to get the debugger to stop for anything until I clicked on the app folder in the project view (one level below root). Clicking on the Root folder of the project didn't work either.
Related
My application is throwing an exception from "com.vaadin.client.ApplicationConnection" class of vaadin 7.4.6 and i want to debug this class to exactly identify the issue.
I'm using IntellijIdea IDE and I'm able to debug the classes in the "com.vaadin.server" package but not in "com.vaadin.client" through Super Dev mode.
Do we need to do anything special for debugging in the "com.vaadin.client" package.
I know that AngularJS by default catches all application exceptions and then logs them to the console. That makes the 'Pause on uncaught exceptions' button in Chrome (which I use a lot) useless.
Many times I encounter small javascript errors in my code (like accessing members on undefined variables) and I'm really used to pausing on the exception and inspecting the situation.
The only solution I have by now is either to put a breakpoint on the code which is triggering the error (impractical) or to use the 'Pause on all exceptions' button, but I have to continue on all errors generated by default by jQuery, Angular and other frameworks, and that's also very nasty.
I also tried overwriting the $exceptionHandler service, and put a breakpoint in it, but I don't have access from the call stack in the function that generated the error.
So, is it possible to use the 'Pause on uncaught exceptions' with AngularJS apps?
According to the Angular docs,
https://docs.angularjs.org/api/ng/service/$exceptionHandler
This example will override the normal action of $exceptionHandler, to
make angular exceptions fail hard when they happen, instead of just
logging to the console.
angular.module('exceptionOverride', []).factory('$exceptionHandler', function() {
return function(exception, cause) {
exception.message += ' (caused by "' + cause + '")';
throw exception;
};
});
This will cause them to be handled by the browser dev tools, which will allow pause on caught exceptions, usage of source maps for nice stack traces, etc.
Presumably you don't want this to happen in production, and also don't want to have to add/remove this code continuously during development. We solve this secondary problem by having a 'dev' module which adds to and overrides our production code during development. For example:
In dev.html:
<html ng-app="devApp">
...
In dev.js:
angular.module('devApp', ['mainApp'])
.factory('$exceptionHandler', ...)
The "Skip stepping through sources" is no longer available in Chrome, but - there is a new option - you can right click any script in sources/sources and choose 'Blackbox script'. Then you can turn on 'Pause on Caught Exceptions' without worrying about jQuery and other errors. Personally I use it always on jquery.js and angular.js.
You can enable Skip stepping through sources with particular names in DevTools and set it to something like this:
(jquery|angular|diigolet)
I am trying to compile the libGDX project using GWT (libgdx-project-html right click -> Google -> GWT Compile).
I get no errors while compiling except
com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Target
java.lang.StringIndexOutOfBoundsException
but since I'm not using this util should not be a problem.
After the compilation says that it was successful, I ran the local hosted site.
LibGDX logo and loading bar come up (fine until here), and when they are done, I get a black game screen and a box below it with unlimited
GwtApplication: exception: (TypeError) : Cannot call method
'nullMethod' of null (TypeError) : Cannot call method 'nullMethod' of
null
message lines.
In the console the following message is repeated continuously:
Uncaught java.lang.RuntimeException:
com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot
call method 'nullMethod' of null (anonymous function)
597957B2399D3903739C615799AE1A15.cache.html:11899
The project basically is nothing but the logo of libGDX that should come up and fill the game screen (the default one) and no code has been modified.
Some additional notes:
Desktop and Android compile and work flawlessly.
Console says SoundManager 2 loaded (OK) before that error message comes up.
Strict flag is set when GWT compiling and everything are compiled with no errors.
For anyone having the same problem or any other similar/weird exceptions.
Make sure that strict flag is set by adding
-strict
in the compiling arguments and most importantly, you are using
GL20
as WebGL is based on GL20 and doesn't support GL10.
I'm getting compile time error when linker option = "SDK Only" with "Failed to resolve Android.App.Fragment" message. It's all started when I added Google Maps support with FragmentActivity to my MonoDroid application.
With Linker option = "None" everything works just fine except of the fact that .apk became huge (~30mb instead of 7mb when link SDK Only enabled)
Error details:
The "LinkAssemblies" task failed unexpectedly.
Mono.Cecil.ResolutionException: Failed to resolve Android.App.Fragment
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.Initialize()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()
I found a lot of similar problems (1, 2, 3) and the only proposed solution was to disable linker which is not the case for my app.
How can I diagnose and fix the issue?
TIA!
Are you referencing Mono.Android.Support.v4 classes everywhere?
I've been struggling with the same issue on and off for a while now. Currently, I have had success in switching to the Alpha channel of Xamarin Updates and using the alpha builds of Xamarin.Android and Xamarin Studio. Running those alphas, I have been able to make release builds with Linking enabled with no issues. Hope that helps!
Eventually GooglePlayServices Xamarin Component has been updated to 12.0.1 and not it could used without any errors even with "SDK Only" linker flag. You can use it right from component store without any bindings pre-compilation.
In a MFC application, where to put a topmost try/catch?
I have a MFC application and I would like to catch all the exceptions and show my own message box.
This is my idea for a topmost try/catch block:
try
{
// What enclose here? Or, where to put this try/catch block?
}
catch( const std::exception& e )
{
::MessageBox(0,e.what(),"I do not know hot to handle this exception, I will terminate",MB_OK);
}
catch(...)
{
::MessageBox(0,"Unknown Excpetion","I do not know hot to handle this exception, I will terminate",MB_OK);
}
::TerminateProcess( ::GetCurrentProcess(), -1 );
But, where can I put the block?
I created a MFC dialog based application with Visual Studio 2010, and compiled it in Release x64, I am on Windows 7.
I throw a std::exception (passing a string to the constructor) in an OnTimer method and without the block I get a message box created by csrss.exe with this generic message
"The exception unknown software exception (0x40000015) occurred in the
application at location 0x5dff61c9."
"Click on OK to terminate the program"
"Click on CANCEL to debug the program"
The message box does not report the string I attached to the exception and so it is not so useful.
I think I get the message box instead of a fancy TaskDialog because I disabled the Windows Error Reporting Service and renamed the WerFault.exe.
Maybe I have to forget my own message box and I need to embrace the new Windows Error Reporting?
The correct way to process unhandled exceptions in an MFC application is by overriding CWinApp::ProcessWndProcException
You may want to only handle certain exception types. If you want to fall back on the default behavior in some circumstances, call the base implementation. If you do not call the base, your app will not shut down.
If you want to display a custom error message and then shut down while avoiding the default message, display your message box and then call DestroyWindow on your main frame/dialog.