我无法使用 google map v2 片段创建活动。自定义片段工作正常,这只是 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" />