在 CollapsingToolbarLayout 上设置 contentscrim 颜色时出错

Error when setting contentscrim color on CollapsingToolbarLayout

我的应用最近开始在任何 activity 或具有 CollapsingToolbarLayout 的片段上崩溃,错误日志如下:

`

Unable to start activity ComponentInfo{com.radioafrica.music/com.radioafrica.music.activity.PlaylistTracks}: android.view.InflateException: Binary XML file line #31: Binary XML file line #31: Error inflating class android.support.design.widget.CollapsingToolbarLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
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/data/com.radioafrica.music/files/instant-run/dex/slice-com.android.support-support-v4-24.0.0-beta1_f8cf3ba4c70f87f407a745b9fa14a2205d0b587c-classes.dex)
at android.support.design.widget.CollapsingToolbarLayout.setStatusBarScrim(CollapsingToolbarLayout.java:663)
at android.support.design.widget

`

当我注释掉 collapsingToolbarLayout.setStatusBarScrim(color); 时,它工作正常,但缺点是我无法设置稀松布颜色并且工具栏上没有显示标题。这是支持库的错误吗?

我通过查看我的 build.gradle 文件并删除可能具有另一个版本的 v4 support library 的任何依赖项,设法消除了错误。似乎库的版本冲突是问题所在。

我遇到了同样的错误,并且长时间盯着我的依赖版本。 然后我尝试删除这一行,一切正常。但是我不明白原因,抱歉。 compile "com.android.support:support-v4:+