My CollapsingToolbarLayout crashes because of Error inflating class android.support.design.widget.CollapsingToolbarLayout.
I updated the android studio last weekend. Before the updated, it works fine. After I updated it, it crashed. However, I tried to downgrade it to 2.0.0 version and it's not working anymore. My coworker has no problem with the CollapsingToolbarLayout. I am not sure what happened.
The error was:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.android/com.test.android.ui.activity.RandomActivity}: android.view.InflateException: Binary XML file line #22: Error inflating class android.support.design.widget.CollapsingToolbarLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class android.support.design.widget.CollapsingToolbarLayout
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.test.android.ui.activity.RefreshableActivity.onCreate(RefreshableActivity.java:31)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)?
at android.app.ActivityThread.access$800(ActivityThread.java:151)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:135)?
at android.app.ActivityThread.main(ActivityThread.java:5254)?
at java.lang.reflect.Method.invoke(Native Method)?
at java.lang.reflect.Method.invoke(Method.java:372)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)?
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)?
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)?
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)?
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)?
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)?
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)?
at com.test.android.ui.activity.RefreshableActivity.onCreate(RefreshableActivity.java:31)?
at android.app.Activity.performCreate(Activity.java:5990)?
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)?
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)?
at android.app.ActivityThread.access$800(ActivityThread.java:151)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:135)?
at android.app.ActivityThread.main(ActivityThread.java:5254)?
at java.lang.reflect.Method.invoke(Native Method)?
at java.lang.reflect.Method.invoke(Method.java:372)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)?
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/com.test.android-1/base.apk)
at android.support.design.widget.CollapsingToolbarLayout.setStatusBarScrim(CollapsingToolbarLayout.java:663)
at android.support.design.widget.CollapsingToolbarLayout.<init>(CollapsingToolbarLayout.java:197)
at android.support.design.widget.CollapsingToolbarLayout.<init>(CollapsingToolbarLayout.java:132)
at java.lang.reflect.Constructor.newInstance(Native Method)?
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)?
at android.view.LayoutInflater.createView(LayoutInflater.java:607)?
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)?
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)?
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)?
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)?
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)?
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelega
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…