我的应用程序最近开始崩溃任何具有以下错误日志的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);
时,它工作正常,但缺点是我不能设置稀松布颜色,标题不会显示在工具栏上。这是支持库的错误吗?
答案 0 :(得分:0)
我设法通过浏览我的build.gradle
文件并删除可能包含v4 support library
的其他版本的任何依赖项来消除错误。似乎库的冲突版本是问题所在。
答案 1 :(得分:0)
我得到了同样的错误,并且长时间盯着我的依赖版本。
然后我尝试删除这一行,一切正常。但我不明白原因,对不起。
compile "com.android.support:support-v4:+