FATAL EXCEPTION:main,膨胀类片段时出错,android.view.InflateException

问题描述 投票:0回答:1

我正在尝试制作地图应用程序。使用按钮链接到MapActivity类,但是当我按下按钮时,应用程序立即崩溃。请告知,如果需要更多信息来解决错误,请随时向我提出要求。

MapActivity.java

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map); //<-- logcat points at this line

    }

活动地图

<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapActivity">



    <include layout="@layout/content_map" /> //<-- this is line 12



</androidx.coordinatorlayout.widget.CoordinatorLayout>

content_map.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".MapActivity"
    tools:showIn="@layout/activity_map"*>


    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.skyfishjy.library.RippleBackground
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/ripple_bg"
        app:rb_color="#0099CC"
        app:rb_radius="32dp"
        app:rb_rippleAmount="4"
        app:rb_duration="3000"
        app:rb_scale="6">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:translationY="-18dp"
            android:src="@drawable/ic_placeholder"/>
    </com.skyfishjy.library.RippleBackground>
    <com.mancj.materialsearchbar.MaterialSearchBar
        style="@style/MaterialSearchBarLight"
        app:mt_speechMode="false"
        app:mt_hint="Search a place"
        app:mt_maxSuggestionsCount="10"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/searchBar"
        android:layout_margin="16dp"
        app:mt_navIconEnabled="true"
        android:elevation="5dp"
        android:outlineProvider="bounds"
        app:mt_placeholder="Search a place"/>

    <Button
        android:id="@+id/btn_find"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="Find Restaurants"
        android:textColor="#FFFFFF"
        android:background="@color/colorPrimary"
        android:layout_margin="16dp"
        android:textStyle="bold"/>

</RelativeLayout>

LogcatContinue from logcat1

java android fatal-error
1个回答
0
投票

基于您的完整堆栈跟踪,您没有在清单中输入API密钥。将以下内容放入清单中的<application>标记下。

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value=" your key here" />

请按照此处的API密钥设置指南进行操作

https://developers.google.com/maps/documentation/android-sdk/get-api-key

© www.soinside.com 2019 - 2024. All rights reserved.