CollapsingToolbarLayout无法运行应用程序崩溃

时间:2016-11-08 07:17:14

标签: android build.gradle android-collapsingtoolbarlayout

如果我将我的依赖项从23.1.1更新到23.2.0,则CollapsingToolbarLayout无效。应用程序崩溃并抛出错误。

java.lang.RuntimeException:android.view.InflateException: Binary XML file line #77: Binary XML file line #77: Error inflating class android.support.design.widget.CollapsingToolbarLayout
                                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
                                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
                                                                                      at android.app.ActivityThread.access$1100(ActivityThread.java:229)
                                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                      at android.os.Looper.loop(Looper.java:148)
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:7331)
                                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
                                                                                   Caused by: android.view.InflateException: Binary XML file line #77: Binary XML file line #77: Error inflating class android.support.design.widget.CollapsingToolbarLayout
                                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
                                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
                                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
 Caused by: java.lang.NoSuchMethodError: No static method setLayoutDirection(Landroid/graphics/drawable/Drawable;I)V in class Landroid/support/v4/graphics/drawable/DrawableCompat; or its super classes (declaration of 'android.support.v4.graphics.drawable.DrawableCompat' appears in /data/app/in.passionconnect.application-1/base.apk)

依赖关系看起来像这样

compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:support-v4:23.2.0'

和我的compileSdkVersion 23 buildToolsVersion“23.0.2”

2 个答案:

答案 0 :(得分:1)

尝试将依赖项com.android.support.***更新到最新版本。这可能会有所帮助。

答案 1 :(得分:1)

您可以尝试使用稳定 24.2.0'

第1步

compileSdkVersion 24
buildToolsVersion "24.0.2"

第2步

 targetSdkVersion 24

然后

第3步

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

最后 Clean-Rebuild-Gradle &跑。