2017-08-09 39 views
0

所以我嘗試連接或整合我的應用程序在Xamarin安卓到Redhat移動應用程序BU我不斷收到錯誤消息「未處理的異常消息發生」。這裏是主要活動Xamarin應用程序的RedHatMobileApps FHSDK錯誤

using System.Collections.Generic; 
using Android.App; 
using Android.Widget; 
using Android.OS; 
using Android.Util; 
using FHSDK; 

namespace helloworld_xamarin 
{ 
    [Activity(Label = "Quickstart HelloWorld", MainLauncher = true, Icon = "@drawable/icon")] 
    public class MainActivity : Activity 
    { 
     private const string Tag = "MainActivity"; 

     protected override async void OnStart() 
     { 
      base.OnStart(); 
      await FHClient.Init(); 
     } 

     protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 

      SetContentView(Resource.Layout.Main); 

      var button = FindViewById<Button>(Resource.Id.button); 
      var result = FindViewById<TextView>(Resource.Id.result); 
      var input = FindViewById<EditText>(Resource.Id.helloTo); 
      button.Click += async delegate 
      { 
       result.Text = "Calling Cloud....."; 
       var response = await FH.Cloud("hello", "GET", null, new Dictionary<string, string>() { { "hello", input.Text } }); 
       if (response.Error == null) 
       { 
        Log.Debug(Tag, "cloudCall - success"); 
        result.Text = (string)response.GetResponseAsDictionary()["msg"]; 
       } 
       else 
       { 
        Log.Debug(Tag, "cloudCall - fail"); 
        Log.Error(Tag, response.Error.Message, response.Error); 
        result.Text = response.Error.Message; 
       } 
      }; 
     } 
    } 
} 

是否有人有經驗將xamarin移動應用程序整合到redhat移動應用程序服務?我已經使用我的應用程序ID,項目ID等填充了fhconfig屬性。我不知道我的問題是因爲我在紅帽子移動應用程序中的新問題

回答

0

在修復與RedHatMobileApps的集成之前,您需要知道實際Rxception是。

「發生未處理的異常」不會告訴你什麼,除非你的異常處理不足。那是因爲在async塊中沒有。

所以嘗試加入一些:

button.Click += async delegate 
{ 
    try { 
     result.Text = "Calling Cloud....."; 
     var response = await FH.Cloud("hello", "GET", null, new Dictionary<string, string>() { { "hello", input.Text } }); 
     if (response.Error == null) 
     { 
      Log.Debug(Tag, "cloudCall - success"); 
      result.Text = (string)response.GetResponseAsDictionary()["msg"]; 
     } 
     else 
     { 
      Log.Debug(Tag, "cloudCall - fail"); 
      Log.Error(Tag, response.Error.Message, response.Error); 
      result.Text = response.Error.Message; 
     } 
    } catch (Exception e) { 
     Android.Util.Log.Error("buttonError", e.Message); 
    } 
}; 

如果不抓住它,看看CurrentDomain_UnhandledExceptionAndroidEnvironment_UnhandledExceptionRaiser這是最後一搏「抓有關異常的一些信息」類型處理器。

一旦獲得了有關異常的更多信息,它將更容易追蹤。

error message

+0

我加上base.on的start()的破發點,並在應用程序立即顯示錯誤消息「ocured未處理的異常消息」。也許在fhsdk中的錯誤不是我的代碼?你有在redhatmobile應用程序的經驗嗎? –

+0

可能 - 可能註釋掉每行指向fhsdk並查看接下來會發生什麼? – GregHNZ

+0

任何人都有紅帽移動應用程序的經驗,請幫助我 –