Error Inflating Class Collapsingtoolbarlayout

Error inflating class android.support.design.widget.CollapsingToolbarLayout in android

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.CollapsingToolbarLayout"

Since you are using androidx and the Material Components Library, you have to use the component in the same library.
Use:

<com.google.android.material.appbar.CollapsingToolbarLayout
..>

Instead of android.support.design.widget.CollapsingToolbarLayout.

Error Inflating CollapsingToolbarLayout

I answered a similar post here Error inflating class CollapsingToolbarLayout

I know there is an accepted answer already, BUT it is not working (or no longer working).

I spend a couple of hours researching on this error, what I came up is this.

First, due to initial release of Android Nougat also known as Android 7.0 (API 24) compileSdkVersion 24 is now available. To do that you have to update your sdk. Step 1

Sample Image

Second, is to update your gradle files (internet connection required). Step 2

Sample Image

Also Update this part of app.gradle

Sample Image

Third (optional) Clean Project, Build Project (Both under Build Tab)

I hope this help someone out there and save some few hours of researching.

Cheers / Happy coding

Hope it helps.

Error inflating class CollapsingToolbarLayout

I found a solution May it work try it:

add below code in gradle build file

compile ('com.android.support:support-v4:23.4.0'){
force = true;
}

Seems like it is having version conflict issue. All support library must be of same version. However, I didn't use v4 support library before and it works.
I don't know why updatimg android studio to 2.1.1 causes the issue.
I just force all v4 library to the same as other support libraries.

Unable to inflate CollapsingToolbarLayout in Android

This code:


<android.support.design.widget.AppBarLayout

android:id="@+id/main_appbar_layout"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_height="wrap_content">

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">

<android.support.v7.widget.Toolbar
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_height="wrap_content">

</android.support.v7.widget.Toolbar>

</android.support.design.widget.CollapsingToolbarLayout>

<android.support.design.widget.TabLayout
app:tabBackground="@color/colorPrimary"
app:tabIndicatorHeight="40dp"
app:tabTextColor="@color/colorAccent"

android:id="@+id/main_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v4.view.ViewPager
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/main_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent">

</android.support.v4.view.ViewPager>

</LinearLayout>

Woks just fine in my Moto X.

All I did was removing this line: app:theme="@style/ActionBarTheme"

and tools:context=".MainActivity"

My gradle file:

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "24.0.1"

defaultConfig {
applicationId "br.com.hinovamobile.deletethis"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'

}

Please try this code and tell me if it works for you. Or try yours in another phone.

Error inflating when adding imageview to collapsingtoolbarlayout Android

Well as the error says :

Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.android.imgedit:mipmap/appbarimage" (7f0c0000)  is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0c0000 a=-1 r=0x7f0c0000}

Its sure that ImageView is not inflating correctly.

Make sure you copy your appbarimage inside drawable folder and change

android:src="@mipmap/appbarimage"

to

android:src="@drawable/appbarimage"

Error inflating class com.google.android.material.appbar.AppBarLayout

You're using AndroidX tags-components which you already have AppCompat dependencies. This will cause other issues too. Go with the Refactor -> Migrate to AndoridX and add the mentioned dependency for the material components too.

In your build.gradle dependencies:

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

It's coming from Material components -> com.google.android.material as you can see so, that's why you get the error.

Remember to update the gradle in the other build.gradle too:

classpath 'com.android.tools.build:gradle:3.2.0'


Related Topics



Leave a reply



Submit