ИСКЛЮЧИТЕЛЬНОЕ ИСКЛЮЧЕНИЕ: main, Ошибка надувания фрагмента класса, android .view.InflateException - PullRequest
0 голосов
/ 06 февраля 2020

Я пытаюсь сделать приложение карты. Использование кнопки для ссылки на класс MapActivity, но приложение сразу падает, когда я нажимаю кнопку. Пожалуйста, сообщите, если для устранения ошибки требуется дополнительная информация, пожалуйста, не стесняйтесь запросить у меня.

MapActivity. java

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

    }

activity_map

<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>

Карта содержимого. 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>

Logcat Продолжить с logcat1

1 Ответ

0 голосов
/ 06 февраля 2020

Исходя из полной трассировки стека, вы не вводили свои ключи 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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...