2016-02-27 107 views
0

我正在嘗試在我的應用程序中使用谷歌地圖。我已經將谷歌服務地圖和位置服務添加到我的應用程序的組件中了。我正在關注教程並查看有關它的含義的文檔被實施,並用於要求谷歌播放服務,這些服務已被分成多個較小的組件。無論如何,當我運行應用程序時出現一個按鈕,表示在我的應用程序中獲得Google Play服務,當我點擊它時會出現一個錯誤。 感謝您的幫助。在Xamarin中使用谷歌地圖Android

未處理的異常:

Android.Content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details? id=com.google.android.gms&pcampaignid=gcore_8115000--- flg=0x80000 pkg=com.android.vending } 

這裏是我的代碼:

//main.xaml 
    <fragment 
      android:id="@+id/map" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      class="com.google.android.gms.maps.MapFragment" /> 
//Main Activity 
     public class MainActivity : Activity, IOnMapReadyCallback 
     { 

     private GoogleMap mMap; 
       protected override void OnCreate(Bundle bundle) 
       { 
         base.OnCreate(bundle); 
         SetContentView(Resource.Layout.Main); 
         SetUpMap(); 
       } 
      private void SetUpMap() 
      { 
       if (mMap == null) 
       { 
         FragmentManager.FindFragmentById<MapFragment>(Resource.Id.map).GetMapAsync(this); 
       } 

      } 
      public void OnMapReady(GoogleMap googleMap) 
      { 
       mMap = googleMap; 
      } 
    } 

Android清單:

<?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app1.app1" android:versionCode="1" android:versionName="1.0"> 
     <uses-sdk android:minSdkVersion="16" /> 
     <application android:label="app1" android:icon="@drawable/Icon" android:theme="@style/CustomActionBarTheme"> 
     <!-- Put your Google Maps V2 API Key here. --> 
     <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="@string/Google_Maps_Key" /> 
     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 
     </application> 

     <uses-permission android:name="android.permission.INTERNET" /> 
     <!-- Allow the application to access Google web-based services. --> 
     <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
     <!-- Google Maps for Android v2 will cache map tiles on external storage --> 
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
     <!-- Google Maps for Android v2 needs this permission so that it may check the connection state as it must download data --> 
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
     <!-- Permission to receive remote notifications from Google Play Services --> 
     </manifest> 

回答

1

大家好,所以我找到了解決我的問題基本上是xamarin模擬器不來與谷歌默認這樣不幸的是我忽視了在模擬器上安裝這些播放服務。所以即使我將它添加到組件中,並且sdk也忘記了這一步。

0

我不知道你做錯了什麼,但看到這個鏈接,它幫助我執行谷歌地圖很多。 ;)

[https://www.youtube.com/watch?v=W6Q0olRPsus][1]

+0

這正是我關注XD的教程,當他安裝谷歌播放服務時,只是一個簡單的問題,您是否使用谷歌播放服務地圖? –

+0

是的,我做了,它的工作;) – DST