我试图在Android 4.4.2(19 API)上使用Google地图fragment
在API 20+上它工作正常,但在19 API我有这个例外:
android.view.InflateException:二进制XML文件行#18:错误 膨胀类片段
fragment_map.xml:
...
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="fill_parent" />
...
MapFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(LAYOUT, container, false);//this row have error on Api 19
ButterKnife.bind(this, view);
SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
// SupportMapFragment mapFragment = (SupportMapFragment) getActivity().getSupportFragmentManager()
// .findFragmentById(R.id.map); //it's not work on 19 API
setupListeners();
return view;
}
清单:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
的gradle:
compile 'com.google.maps.android:android-maps-utils:0.4.3'
完整错误:
E / AndroidRuntime:致命异常:主要 处理:ru.company.getpizza,PID:10968 android.view.InflateException:二进制XML文件行#18:错误膨胀类片段 在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713) 在android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 在android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 在android.view.LayoutInflater.inflate(LayoutInflater.java:492) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) 在android.view.LayoutInflater.inflate(LayoutInflater.java:397) at ru.copmany.getpizza.fragments.MapFragment.onCreateView(MapFragment.java:119) 在android.support.v4.app.Fragment.performCreateView(Fragment.java:1974) 在android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) 在android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252) 在android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742) 在android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) 在android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570) 在android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:164) 在android.support.v4.view.ViewPager.populate(ViewPager.java:1177) 在android.support.v4.view.ViewPager.populate(ViewPager.java:1025) 在android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1545) 在android.view.View.measure(View.java:17040) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5395) 在android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621) 在android.widget.LinearLayout.measureVertical(LinearLayout.java:742) 在android.widget.LinearLayout.onMeasure(LinearLayout.java:607) 在android.view.View.measure(View.java:17040) 在android.widget.LinearLayout.measureVertical(LinearLayout.java:926) 在android.widget.LinearLayout.onMeasure(LinearLayout.java:607) 在android.view.View.measure(View.java:17040) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5395) 在android.widget.FrameLayout.onMeasure(FrameLayout.java:340) 在android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) 在android.view.View.measure(View.java:17040) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5395) 在android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621) 在android.widget.LinearLayout.measureVertical(LinearLayout.java:742) 在android.widget.LinearLayout.onMeasure(LinearLayout.java:607) 在android.view.View.measure(View.java:17040) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5395) 在android.widget.FrameLayout.onMeasure(FrameLayout.java:340) 在android.view.View.measure(View.java:17040) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5395) 在android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621) 在android.widget.LinearLayout.measureVertical(LinearLayout.java:742) 在android.widget.LinearLayout.onMeasure(LinearLayout.java:607) 在android.view.View.measure(View.java:17040) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5395) 在android.widget.FrameLayout.onMeasure(FrameLayout.java:340) 在com.android.internal.policy.impl.PhoneWindow $ DecorView.onMeasure(PhoneWindow.java:2473) 在android.view.View.measure(View.java:17040) 在android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2412) 在android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1380) 在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1651) 在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1257) 在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6424) 在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:788) 在android.view.Choreographer.doCallbacks(Choreographer.java:591) 在android.view.Choreographer.doFrame(Choreographer.java:560) 在android.view.Choreographer $ FrameDisplayEventRe