我已经在Google Maps
中编码了一个Xamarin
应用程序,并且收到此错误:
Android.Views.InflateException:二进制XML文件第1行:错误膨胀类片段
运行以下代码行时出现此错误:
SetContentView(Resource.Layout.MapWithOverlayLayout);
这是我的MapWithOverlayLayout.axml
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment class="SimpleMapDemo.MapWithMarkersActivity"
android:id="@+id/mapWithOverlay"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
该命名空间称为:SimpleMapDemo
这是我的课堂宣言:
public class MapWithMarkersActivity : Android.Support.V4.App.FragmentActivity
我正在使用SupportMapFragment
对象显示Google Map
我可以帮助您使此代码正常工作吗?
我认为问题出在您在fragment元素上设置的class属性。您是否厌倦了没有它的布局的膨胀?
我已经自己弄清楚了。我的班级名称不正确。
这里是正确的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
我遇到了同样的问题,并通过删除VS或XS中obj / Debug / android目录中的AndroidManifest并将其重写以使其仅对我有效,来解决此问题
这是因为该应用无法区分Google Play服务清单和该应用的清单。