webentwicklung-frage-antwort-db.com.de

Fehler beim Aufblasen der Klasse com.google.Android.material.appbar.AppBarLayout

Ich habe xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:Android="http://schemas.Android.com/apk/res/Android"
    xmlns:app="http://schemas.Android.com/apk/res-auto"
    Android:id="@+id/drawerLayout"
    Android:layout_width="match_parent"
    Android:layout_height="match_parent">

    <RelativeLayout
        Android:layout_width="match_parent"
        Android:layout_height="match_parent">

        <com.google.Android.material.appbar.AppBarLayout
            Android:id="@+id/appBarLayout"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:elevation="0dp">
            <androidx.appcompat.widget.Toolbar
                Android:id="@+id/toolbarMainActivity"
                style="@style/CustomToolbar"
                Android:background="@color/biscay"
                app:layout_scrollFlags="scroll|enterAlways">

                <RelativeLayout
                    Android:layout_width="match_parent"
                    Android:layout_height="match_parent">

                    <ImageButton
                        Android:id="@+id/icon_drawer_imagebutton"
                        Android:layout_width="wrap_content"
                        Android:layout_height="wrap_content"
                        Android:layout_alignParentRight="true"
                        Android:layout_centerVertical="true"
                        Android:background="@null"
                        Android:paddingLeft="10dp"
                        Android:paddingRight="10dp"
                        app:srcCompat="@drawable/ic_drawer" />

                    <RelativeLayout
                        Android:gravity="center_horizontal"
                        Android:layout_width="match_parent"
                        Android:layout_height="match_parent"
                     Android:layout_toLeftOf="@+id/icon_drawer_imagebutton">

                        <ImageButton
                            Android:id="@+id/icon_logo_imagebutton"
                            Android:layout_width="@dimen/size_logo"
                            Android:layout_height="@dimen/size_logo"
                            Android:layout_alignParentRight="true"
                            Android:layout_centerVertical="true"
                            Android:adjustViewBounds="true"
                            Android:background="@null"
                            Android:scaleType="fitXY"
                            app:srcCompat="@drawable/ic_logo_white" />

                        <TextView
                            Android:id="@+id/nameUniversity_textview"
                            Android:layout_width="wrap_content"
                            Android:layout_height="match_parent"
                            Android:layout_centerHorizontal="true"
                            Android:layout_centerVertical="true"
                            Android:layout_marginLeft="10dp"
                            Android:layout_marginRight="10dp"
                            Android:textSize="18sp"
                         Android:layout_toLeftOf="@+id/icon_logo_imagebutton"
                            Android:gravity="center_vertical"
                            Android:text="@string/nameUniversity"
                            Android:textColor="@color/colorTextLight"
                            Android:textStyle="bold" />
                    </RelativeLayout>
                </RelativeLayout>
            </androidx.appcompat.widget.Toolbar>
        </com.google.Android.material.appbar.AppBarLayout>

        <com.google.Android.material.tabs.TabLayout
            Android:id="@+id/tabsMainActivity"
            style="@style/CustomTabLayout"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_below="@+id/appBarLayout"
            app:tabGravity="fill"
            app:tabMode="fixed" />

        <androidx.viewpager.widget.ViewPager
            Android:id="@+id/viewpagerMainActivity"
            Android:layout_width="match_parent"
            Android:layout_height="match_parent"
            Android:layout_below="@+id/tabsMainActivity"
            Android:background="@color/colorTextLight" />
    </RelativeLayout>
    <!-- Navigation Drawer-->
    <androidx.recyclerview.widget.RecyclerView
        Android:id="@+id/drawerRecyclerView"
        Android:layout_width="300dp"
        Android:layout_height="match_parent"
        Android:layout_gravity="right"
        Android:background="@color/gallery" />
</androidx.drawerlayout.widget.DrawerLayout>

Und meine Bibliothek ist:

implementation 'com.Android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation 'com.Android.support:exifinterface:28.0.0'
implementation 'com.Android.support:appcompat-v7:28.0.0'
implementation 'com.Android.support:recyclerview-v7:28.0.0'
implementation 'com.Android.support:cardview-v7:28.0.0'
implementation 'com.Android.support:design:28.0.0'
implementation 'com.Android.support:support-vector-drawable:28.0.0'
implementation 'com.Android.support:multidex:1.0.3'

Aber hol mir unten Fehler:

Caused by: Android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class com.google.Android.material.appbar.AppBarLayout
Caused by: Android.view.InflateException: Binary XML file line #12: Error inflating class com.google.Android.material.appbar.AppBarLayout
Caused by: Java.lang.reflect.InvocationTargetException
7
jo jo

Sie verwenden AndroidX Tags-Komponenten, für die Sie bereits AppCompat Abhängigkeiten haben. Dies wird auch andere Probleme verursachen. Gehen Sie mit dem Refactor -> Migrate to AndoridX Und fügen Sie die erwähnte Abhängigkeit auch für die Materialkomponenten hinzu.

In Ihren build.gradle Abhängigkeiten:

implementation 'com.google.Android.material:material:1.0.0'

Es kommt von Materialkomponenten-> com.google.Android.material, Wie Sie sehen können, deshalb erhalten Sie den Fehler.

Denken Sie daran, das gradle auch im anderen build.gradle Zu aktualisieren:

classpath 'com.Android.tools.build:gradle:3.2.0'
7
ʍѳђઽ૯ท