Google地图膨胀异常

我试图在Android 4.4.2(19 API)上使用谷歌地图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 )at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)at android.view.LayoutInflater.inflate(LayoutInflater.java:492)at uk.co .chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)在android.view.LayoutInflater.inflate(LayoutInflater.java:397)在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)at a ndroid.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.View.get.ViewPager.onMeasure(ViewPager.java:1545)at android.view.View.measure(View.java:17040)at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5395)at 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.java:17040 android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5395)android.widget.FrameLayout.onMeasure(FrameLayout.java:340)在android.support上的android.view.java:17040。 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(查看。在android.view.View.measure(View.java:17040)处的android.widget.FrameLayout.onMeasure(FrameLayout.java:340)处的android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5395) android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5395)在android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)在android.widget.LinearLa 在android.view.View.measure(View.java:17040)android.view.ViewGroup.measureChildWithMargins(ViewGroup)android.widget.LinearLayout.onMeasure(LinearLayout.java:607)上的yout.measureVertical(LinearLayout.java:742)的.java:5395)在android.widget.FrameLayout.onMeasure(FrameLayout.java:340)在com.android.internal.policy.impl.PhoneWindow $ DecorView.onMeasure(PhoneWindow.java:2473)在android.view.View。测量(View.java:17040)在android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2412)在android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1380)在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java :1651)at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1257)at android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6424)at android.view.Choreographer $ CallbackRecord.run(Choreographer.java: 788)在android.view.Choreographer.doCallbacks(Choreographer.java:591)在android.view.Choreographer.doFrame(Choreographer.java:560)在android.view.Choreograp 她$ FrameDisplayEventRe

链接地址: http://www.djcxy.com/p/93047.html

上一篇: Google map inflate exception

下一篇: YouTubePlayerSupportFragment No views can be added on top of the player