2015-06-09 97 views
0

我很難試圖在我的Xamarin Forms應用程序上顯示地圖。這是我得到每次錯誤我打開網頁與地圖:Xamarin.Forms地圖崩潰的應用程序

0x29 in System.Diagnostics.Debugger.Mono_UnhandledException_internal C# 
0x1 in System.Diagnostics.Debugger.Mono_UnhandledException C# 
0x6 in Android.Runtime.UncaughtExceptionHandler.UncaughtException at /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/src/Runtime/UncaughtExceptionHandler.cs:35,4 C# 
0x1C in Java.Lang.Thread.IUncaughtExceptionHandlerInvoker.n_UncaughtException_Ljava_lang_Thread_Ljava_lang_Throwable_ at /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Java.Lang.Thread.cs:221,5 C# 
0x1D in object.28d67210-c8ee-4f17-9d83-36104107982d C# 

這是創建頁面的代碼:

var topLayout = new StackLayout 
{ 
    Children = 
    { 
     new Map(MapSpan.FromCenterAndRadius(new Position(37,-122), Distance.FromMiles(0.3))) 
     { 
      IsShowingUser = true, 
      HeightRequest = 100, 
      VerticalOptions = LayoutOptions.FillAndExpand 
     } 
    } 
}; 

var bottomLayout = new StackLayout { Children = { ... } }; //shortened for readability 

Content = new StackLayout 
{ 
    Children = { topLayout, bottomLayout } 
}; 

我說這個問題是地圖,因爲如果例如,我更改標籤的「新地圖」行。

我實例化地圖FW這裏說:http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/maps/

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

    global::Xamarin.Forms.Forms.Init(this, bundle); 
    Xamarin.FormsMaps.Init(this, bundle); 
    LoadApplication(new FullHelp.App()); 
} 
+0

你沒有發佈異常名稱。請添加它。順便說一下,在最新的xamarin中,他們打破了異常堆棧跟蹤。嘗試安裝舊的(8.9應該是OK)並查看確切的異常。 – Grigory

+0

您是否還在配置中添加了Maps鍵並檢查了所需的權限? –

+0

@GeraldVersluis不,但根據提供的文件,這不應該是一個問題。在他們說的鏈接,如果你不提供地圖鍵xamarin會顯示一個灰色的框。關於我讓這一個滑落的權限,我會嘗試。謝謝。 – eestein

回答

3

我想你的解決方案Android,是的它確實拋出Exception

Debug --> Exceptions對話框中,如果您單擊了Thrown複選框Common Language Runtime Exceptions,您將得到一個更有意義的要解決的異常的描述。

enter image description here

引發的異常細節是:

'Java.Lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.geo.API_KEY" android:valu…' 

看你AndroidManifest.xml你沒有定義的鍵/功能。

參考this link,將討論如何配置您的Xamarin.Forms應用程序來處理Maps集成,因爲您似乎缺少一些內容。

有關我的其他StackOverflow答案here的詳細信息,詳細介紹瞭如何爲Andorid創建API密鑰。

+0

謝謝,雖然我不明白爲什麼Xamarin教程說他們不需要測試。感謝您的幫助和時間。 – eestein

1

按住短鍵Ctrl+Alt+E在Visual Studio中打開例外。