二进制XML文件行#17:二进制XML文件行#17:错误膨胀类android.support.design.widget.CollapsingToolbarLayout

时间:2016-12-06 10:42:10

标签: android android-layout android-fragments

我正在开展一个项目,我有一个活动,其中我有CollapsingToolbarLayout。它正在我的旧设备上工作,但当我尝试在Marshmallow上打开应用程序时,它会抛出以下错误。我尝试了一切。请帮帮我。

12-06 16:08:09.658 15112-15112/? E/AndroidRuntime: FATAL EXCEPTION: main
                                               Process: com.kpgames.shravammusicplayer, PID: 15112
                                               java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kpgames.shravammusicplayer/com.kpgames.shravanmusicplayer.activity.ArtistDetailActivity}: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: 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: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class android.support.design.widget.CollapsingToolbarLayout
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                                   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                   at com.kpgames.shravanmusicplayer.activity.ArtistDetailActivity.onCreate(ArtistDetailActivity.java:41)
                                                   at android.app.Activity.performCreate(Activity.java:6237)
                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                   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: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.widget.CollapsingToolbarLayout
                                                   at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                                   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
                                                   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                   at com.kpgames.shravanmusicplayer.activity.ArtistDetailActivity.onCreate(ArtistDetailActivity.java:41) 
                                                   at android.app.Activity.performCreate(Activity.java:6237) 
                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                   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.reflect.InvocationTargetException
                                                   at java.lang.reflect.Constructor.newInstance(Native Method)
                                                   at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                                                   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
                                                   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                   at com.kpgames.shravanmusicplayer.activity.ArtistDetailActivity.onCreate(ArtistDetailActivity.java:41) 
                                                   at android.app.Activity.performCreate(Activity.java:6237) 
                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                   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/app/com.kpgames.shravammusicplayer-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 android.view.LayoutInflater.createView(LayoutInflater.java:619) 
                                                   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
                                                   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                   at com.kpgames.shravanmusicplayer.activity.ArtistDetailActivity.onCreate(ArtistDetailActivity.java:41) 
                                                   at android.app.Activity.performCreate(Activity.java:6237) 
                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                   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

布局

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/app_bar_height"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/AppTheme.PopupOverlay" />
        <ImageView
            android:id="@+id/art_blur"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingTop="60dp"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/image_art"
                android:layout_width="150dp"
                android:layout_height="150dp"
                android:layout_centerInParent="true"
                android:layout_gravity="center"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:transitionName="transition_artist_image" />

            <TextView
                android:id="@+id/txtName"
                android:text="TextView"
                style="@style/AppTheme.TextAppearance"
                android:layout_centerInParent="true"
                android:layout_gravity="center"
                android:textSize="20dp"
                android:paddingTop="10dp"
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />


            <!--<TextView-->
                <!--android:id="@+id/txtAlbum"-->
                <!--android:text="TextView"-->
                <!--style="@style/AppTheme.TextAppearance"-->
                <!--android:layout_centerInParent="true"-->
                <!--android:layout_gravity="center"-->
                <!--android:textSize="15dp"-->
                <!--android:gravity="center"-->
                <!--android:layout_width="match_parent"-->
                <!--android:layout_height="wrap_content" />-->

        </LinearLayout>
    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_artist_detail" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/fab_margin"
    app:layout_anchor="@id/app_bar"
    app:layout_anchorGravity="bottom|end"
    app:srcCompat="@android:drawable/ic_media_play"
    app:backgroundTint="@android:color/holo_red_dark" />

1 个答案:

答案 0 :(得分:0)

似乎它是gradle中的版本冲突问题。所有android支持库必须具有相同的版本,因此只需强制所有v4库与其他支持库相同。

在gradle文件下面添加

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