Error inflating class CollapsingToolbarLayout

烈酒焚心 提交于 2019-11-27 12:45:21
Shumin

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.

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

I spent a couple of hours researching on this error, what I came up was 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

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

Also Update this part of app.gradle

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

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

Cheers / Happy coding

Numan Turkeri

i found two solutions,

first one is

app:statusBarScrim="@null"

second is to force app

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

Sources taken from here

I had the same issue, @Shumin's code is effective too but it is better to remove conflicts instead of bypassing them. To find the conflict -

  1. In Android Studio, open Terminal and enter gradlew app:dependencies.

  2. Check the dependencies tree and see which library is causing conflict

Update:- To check for conflicts, check the dependencies of each library and see if you aren't using the same dependency in some other library but with different version. For example, in the image below, com.android.support:appcompat-v7 is dependent on com.android.support:support-vector-drawable:23.4.0. If you find some other library depending on com.android.support:support-vector-drawable but the version is different, then you have found your conflict.

My issue was that not all of the support library gradle imports we the same, eg, I had:

  compile('com.android.support:recyclerview-v7:23.4.0') {
        exclude module: 'support-v4'
    }
  compile 'com.android.support:support-annotations:24.0.0'

changing it so all imports were 24.0.0 enabled the application to run without issues.

Hello Friend i face this issue

Just Make

compileSdkVersion 25
buildToolsVersion "25.0.2"

And All support gradle change to 25.1.1 it's work for me .

please add below code in menifiest.xml.

 <activity android:name=".MainActivity"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

and style resource file

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

I had the same issue showing the same error while inflating the CollapsingToolbar.. I had the following dependencies in my app gradle file

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.google.firebase:firebase-ads:10.0.1'

and build tool 25.0.2 with compiled with API 23 sdk. I than checked the dependencies and found that firebase uses

android:support:support-v4:24.0.0

and the appcompat uses

android:support:support-v4-23.4.0 -> 24.0

Hence, I changed all the build library number to

compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.google.firebase:firebase-ads:10.0.1'

It worked for me now. How durable ? I don't have any idea.

This worked for me. Change you your appcompact and design libray version as follows,

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'

If you are working on Oreo or upper sdk and using a drawable in CollapsingToolbar, check this drawable exists in normal drawable folder and drawable-v24 folder.

If your drawable is only in drawable-v24 folder and running the app under Oreo sdk, Android Studio logcat says "crash in CollapsingToolbar" but real problem is missing some drawables in your drawable folder.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!