android.view.InflateException:二进制XML文件行#170:错误膨胀类片段

时间:2016-12-09 20:35:19

标签: android google-maps listview android-fragments google-maps-api-3

我在清单文件中添加google maps API后活动崩溃了。我在Activity中的另一个片段中添加了一个地图片段但是如果我添加了API文件崩溃了。请帮助。这是我的完整错误 -

     android.view.InflateException: Binary XML file line #170: Error inflating class fragment
                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:767)
                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:810)
                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
                                                                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:508)
                                                                    at android.view.LayoutInflater.inflate(LayoutInflater.java:418)
                                                                    at com.gjs.placesjson.BookFragment.onCreateView(BookFragment.java:90) //THis is view Inflate
                                                                    at android.support.v4.app.Fragment.performCreateView(Fragment.java:2080)
                                                                    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1108)
                                                                    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290)
                                                                    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
                                                                    at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1638)
                                                                    at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:679)
                                                                    at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
                                                                    at android.support.v4.view.ViewPager.populate(ViewPager.java:1240)
                                                                    at android.support.v4.view.ViewPager.populate(ViewPager.java:1088)
                                                                    at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1614)
                                                                    at android.view.View.measure(View.java:17562)
                                                                    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                    at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:700)
                                                                    at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
                                                                    at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1364)
                                                                    at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:765)
                                                                    at android.view.View.measure(View.java:17562)
                                                                    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                    at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                    at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                                                                    at android.view.View.measure(View.java:17562)
                                                                    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                                    at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                                    at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                                    at android.view.View.measure(View.java:17562)
                                                                    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                    at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                    at android.view.View.measure(View.java:17562)
                                                                    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)

这里是问题显示在第170行的布局

      <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        tools:context=".MapsActivity"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_height="200dp"
        android:layout_marginTop="30dp"
        android:layout_width="340dp" />

提前致谢

1 个答案:

答案 0 :(得分:0)

你有没有添加这个库:

compile 'com.google.android.gms:play-services-maps:10.0.1'

然后重建项目。