0

basically I upgraded to androidx and im having the error :

I tried to change in whole project the xml files to update them from th new androidx library ,still don't understand whats the problem .Thanks in advance

any idea how to solve this?

java.lang.RuntimeException: Unable to start activity ComponentInfo{}: android.view.InflateException: Binary XML file line #11: Could not inflate Behavior subclass android.support.design.widget.AppBarLayout$ScrollingViewBehavior
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6944)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

here is my xml file :

activty_tracking_drawer

    <?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_tracking_activity_drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_tracking_activity_drawer"
        app:menu="@menu/activity_tracking_drawer_drawer" />

</androidx.drawerlayout.widget.DrawerLayout>

here is my app_bar_tracking_activity_drawer :

  <?xml version="1.0" encoding="utf-8"?>
<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=".Tracking.TrackingActivityDrawer">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" >


            <ImageView
                android:id="@+id/your_icon"
                android:layout_width="200dp"
                android:layout_height="50dp"
                android:src="@drawable/maintoolbar" />


            <ImageView
                android:id="@+id/toolbarDogProfile"
                android:layout_width="100dp"
                android:layout_height="50dp"
                android:src="@drawable/beni" />



        </androidx.appcompat.widget.Toolbar>


    </com.google.android.material.appbar.AppBarLayout>

    <include layout="@layout/content_tracking_activity_drawer" />


</androidx.coordinatorlayout.widget.CoordinatorLayout>

here is my gradle file :

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])


implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.vectordrawable:vectordrawable:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'

Checked too,to start another activity but the problem is there even when I changed the xml to androidx its still gives me multiple errors Error inflating class

Petar Ceho
  • 114
  • 2
  • 7

2 Answers2

0

Your layout xml file for ComponentInfo still has an entry for android.support.design.widget.AppBarLayout which is the old support library version.

You need to change it to com.google.android.material.appbar.AppBarLayout which is part of the newer material library.

Whenever you see an InflateException like the one you've got:

android.view.InflateException: Binary XML file line #11

It means that the framework was unable to inflate your xml file due to a problem. You can see that it also gives you the line number where it encountered the problem and also a summary:

Could not inflate Behavior subclass android.support.design.widget.AppBarLayout$ScrollingViewBehavior

In this case it's telling you that you are referencing a ScrollingViewBehaviour from the old library which it can't find. You likely just need to update the reference to the new library and it will work properly.

Jahnold
  • 7,623
  • 2
  • 37
  • 31
0

Found the solution here basically in Content_main change

the app:layout_behavior value to app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"

What's alternative to 'AppBarLayout$ScrollingViewBehavior' in AndroidX?

Petar Ceho
  • 114
  • 2
  • 7