2016-11-22 7 views
0

私はアンドロイド用のXamarin(Visual studio 2015で)を使用してアプリケーションを開発中です。クラッシュアプ​​リケーションをデバッグする方法

私はアプリケーションをデバッグモードで実行すると、アプリケーション停止時に "MyApplication has stopped"というメッセージが表示されることがあります。

私はMainActivityにこのコードを追加しました:

// Catch Exception 
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; 
AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser; 

私はブレークポイントが両方の機能でログを追加しますが、私はログに痕跡を見ていないし、ブレークポイントに達していない追加。

どのようにこの種の問題をデバッグできますか?

答えて

1

永続的なロガー、つまりadb logcatでアプリケーションをデバッグする必要があります。残念ながら、未処理の例外ハンドラを登録しても、その時点まで到達しない可能性があるため、「キャッチオール」になるとは限りません。したがって、これらのタイプの問題にはadb logcatConsole.WriteLineの組み合わせが必要です。このハンドラ内で何が起こっているのかを見たいときは、次の注意を考慮してください。また、最初に衝突の理由を確認するにはadb logcatを使用してください。

/// <summary> 
/// When app-wide unhandled exceptions are hit, this will handle them. Be aware however, that typically 
/// android will be destroying the process, so there's not a lot you can do on the android side of things, 
/// but your xamarin code should still be able to work. so if you have a custom err logging manager or 
/// something, you can call that here. You _won't_ be able to call Android.Util.Log, because Dalvik 
/// will destroy the java side of the process. 
/// </summary> 

protected void HandleUnhandledException (object sender, UnhandledExceptionEventArgs args) 
{ 
    Exception e = (Exception) args.ExceptionObject; 

    // log won't be available, because dalvik is destroying the process 
    //Log.Debug (logTag, "MyHandler caught : " + e.Message); 
    // instead, your err handling code shoudl be run: 
    Console.WriteLine ("========= MyHandler caught : " + e.Message); 
} 

https://github.com/xamarin/monodroid-samples/blob/fb9d4ed266bdf68bb1f9fa9933130b285712ec82/AdvancedAppLifecycleDemos/HandlingCrashes/App.cs

1

試用:Androidビルドオプションで「共有ランタイムを使用」を無効にしました。試しに役立たない場合は、「早送りを使用する」を無効にしてください。

関連する問題