2013-07-03 42 views
0

我无法使用google map v2片段创建活动。自定义片段工作正常,这只是一个MapFragment的问题。MvvmCross与MapFragment

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
<fragment 
    class="com.google.android.gms.maps.SupportMapFragment" 
    android:id="@+id/mapfragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

以下是错误:

mvx:Diagnostic: 36.27 Showing ViewModel TruckWashMapViewModel 
[0:] mvx:Diagnostic: 36.27 Showing ViewModel TruckWashMapViewModel 
07-03 17:24:51.184 I/mono-stdout(16230): mvx:Diagnostic: 36.27 Showing ViewModel TruckWashMapViewModel 
07-03 17:24:51.214 I/Choreographer(16230): Skipped 297 frames! The application may be doing too much work on its main thread. 
Resolved pending breakpoint at 'c:\_Application\BLUBCNMOBL\src\BLUBCNMOBL.Droid\Views\TruckWashMapView.cs:17,1' to OnCreate [0x00001]. 
[0:] mvx:Diagnostic: 40.71 Loading new ViewModel from Intent with Extras 
[0:] mvx:Diagnostic: 40.71 Loading new ViewModel from Intent with Extras 
07-03 17:24:55.629 I/mono-stdout(16230): mvx:Diagnostic: 40.71 Loading new ViewModel from Intent with Extras 
[0:] 
MvxBind:Error: 42.60 View type not found - fragment 
[0:] MvxBind:Error: 42.60 View type not found - fragment 
07-03 17:24:57.511 I/mono-stdout(16230): MvxBind:Error: 42.60 View type not found - fragment 

通过堆栈跟踪翻翻进一步,它看起来就像是用API密钥错误。但是我在AndroidManifest.xml中有我的API密钥。

07-05 14:55:02.231 I/MonoDroid(31877): Caused by: java.lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml 

AndroidManifest.xml中

<application android:icon="@drawable/logo" 
       android:debuggable="true" 
       android:enabled="true" 
       android:persistent="false" 
       android:allowClearUserData="true"> 
     <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="xxx" /> 

回答

1

我应该发布我的整个AndroidManifest.xml。问题是我在清单中有2个Application节点。

+0

哇。这也打动了我 - 谢谢你。 – wgraham

+0

同一个盲人混蛋在这里:) –

0

发生的任何片段这个问题?或只是为了一个地图片段?

你可以使用ViewGroup解决这个问题并动态加载你的片段吗?

作为参考,所述N + 1个视频对片段包括<fragment>标签 - N = 26 - 这表明被加载片段并用的NuGet包被记录3.0.8.1

参见

如果它的所有片段被打破现在,那么我想拥有的东西自3.0.8.1版本以来破裂 - 在这种情况下,报告项目的问题和/或修复。

如果这个问题是特定于你的地图导入,那么我想你将不得不做更多的调试和调查才能解决问题。

+0

我在问题中添加了更多信息。这只发生在Google地图片段中,并且我发现堆栈跟踪中有更多信息说没有找到API密钥。 –

+0

谢谢。我不知道mvx会干扰api密钥查找 - 因此我无法再对此进行评论。注意 - 我并不是说这与MvvmCross没什么关系 - 但我想说,你的新更新表明mvvmCross更像是旁观者(我们可能在错误的时间站在错误的地方) ...但目前没有真正的线索,关于如何或为什么或在哪里放置正确的地方!)。希望能够理解Xamarin.Android-Java-GooglePlay关系的人能够提供帮助。祝你好运! – Stuart

0

如果您正在使用MvvmCross的未修改版本(3.0.8.1),那么你需要使用的,而不是com.google.android.gms.maps.MapFragment

com.google.android.gms.maps.SupportMapFragment尝试使用它来显示地图片段

<fragment 
    class="com.google.android.gms.maps.SupportMapFragment" 
    android:id="@+id/mapfragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

我观察到与API密钥类似的问题。我是由Google API控制台中的错误设置导致的。实际上有两种服务可供选择“Google Maps Android API v2”和“Google Maps API v2”。您能否在服务标签中确认您确实已启动“Google Maps Android API v2”服务。

+0

你是对的,我使用了错误的MapFragment。当我离开代码这样我得到一个地图片段错误。现在我将它切换到SupportMapFragment,我收到了API密钥错误。更新了问题,谢谢。 –