Android CollapsingToolbarLayout错误膨胀



我有ActivityAppBarLayout里面。在AppBarLayout我有CollapsingToolbarLayoutFrameLayoutToolbar。当我尝试使用此Activity启动应用程序时,应用程序崩溃并出现错误:

07-01 10:46:11.790 4912-4912/com.rcd.perfecto E/AndroidRuntime: FATAL EXCEPTION: main
                                                            Process: com.rcd.perfecto, PID: 4912
                                                            android.view.InflateException: Binary XML file line #13: Binary XML file line #13: 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 com.rcd.perfecto.ui.fragments.AboutAppFragment.onCreateView(AboutAppFragment.java:36)
                                                                at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074)
                                                                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
                                                                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
                                                                at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758)
                                                                at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671)
                                                                at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:532)
                                                                at android.os.Handler.handleCallback(Handler.java:739)
                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                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 #13: 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 com.rcd.perfecto.ui.fragments.AboutAppFragment.onCreateView(AboutAppFragment.java:36) 
                                                                at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074) 
                                                                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 
                                                                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286) 
                                                                at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758) 
                                                                at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671) 
                                                                at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:532) 
                                                                at android.os.Handler.handleCallback(Handler.java:739) 
                                                                at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                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 com.rcd.perfecto.ui.fragments.AboutAppFragment.onCreateView(AboutAppFragment.java:36) 
                                                                at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074) 
                                                                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 
                                                                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286) 
                                                                at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758) 
                                                                at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671) 
                                                                at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:532) 
                                                                at android.os.Handler.handleCallback(Handler.java:739) 
                                                                at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                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.rcd.perfecto-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 com.rcd.perfecto.ui.fragments.AboutAppFragment.onCreateView(AboutAppFragment.java:36) 
                                                                at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074) 
                                                                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 
                                                                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286) 
                                                                at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758) 
                                                                at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671) 
                                                                at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:532) 
                                                                at android.os.Handler.handleCallback(Handler.java:739) 
                                                                at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                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) 

我已经尝试改变我的支持库的版本,但它没有帮助。这是我的Gradle依赖项:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile('com.github.afollestad.material-dialogs:commons:0.8.5.5@aar') {
        transitive = true
    }
//picture util
    compile('com.google.api-client:google-api-client-android:1.20.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile('com.google.apis:google-api-services-drive:v2-rev170-1.20.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile 'com.github.bumptech.glide:glide:3.7.0'
//View
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
    compile "com.android.support:appcompat-v7:${google_support_library}"
    compile "com.android.support:design:${google_support_library}"
    compile "com.android.support:palette-v7:${google_support_library}"
    compile "com.android.support:cardview-v7:${google_support_library}"
    compile "com.android.support:recyclerview-v7:${google_support_library}"
    compile 'com.android.support:support-v4:23.4.0'
    compile "com.google.android.gms:play-services-drive:${play_services_version}"
    compile "com.google.android.gms:play-services-appindexing:${play_services_version}"
    compile "com.google.android.gms:play-services-cast:${play_services_version}"
    compile "com.google.android.gms:play-services-maps:${play_services_version}"
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'jp.wasabeef:picasso-transformations:2.1.0'
    compile 'com.dropbox.core:dropbox-core-sdk:2.0.1'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0'
    compile 'com.google.code.gson:gson:2.6.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.yqritc:recyclerview-flexibledivider:1.2.9'
    compile 'com.yandex.android:disk-restapi-sdk:1.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'com.onedrive.sdk:onedrive-sdk-android:1.2.0'
    compile 'com.microsoft.services.msa:msa-auth:0.8.4'
    compile 'com.microsoft.aad:adal:1.1.11'
    compile 'com.flickr4java:flickr4java:2.16'
    compile 'com.kogitune:pre-lollipop-activity-transition:1.3.0'
    compile 'com.github.pinball83:masked-edittext:1.0.2'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.github.jpardogo:PagerSlidingTabStrip:v1.1.0'
    compile 'it.sephiroth.android.library.imagezoom:imagezoom:1.0.5'
    compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32@aar'
    compile 'com.github.rtoshiro.fullscreenvideoview:fullscreenvideoview:1.1.0'
    compile 'com.miguelcatalan:materialsearchview:1.4.0'
    compile 'com.getbase:floatingactionbutton:1.10.1'
    compile 'com.github.chrisbanes:PhotoView:1.2.6'
    compile 'com.github.lipangit:jiecaovideoplayer:v3.1'
    compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.0.4'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile project(':ucrop')
    compile project(':4digitpin')
}
这是我的布局文件:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.rcd.perfecto.ui.fragments.AboutAppFragment">
<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <android.support.design.widget.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:animateLayoutChanges="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginBottom="20dp"
        app:expandedTitleMarginStart="20dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="@dimen/about_fragment_height_toolbar" />
        <include
            android:id="@+id/toolbar"
            layout="@layout/app_bar" />
    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="15dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/tv_licenses_header"
            android:textColor="@color/colorPrimaryDark"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:textSize="16sp"/>
        <android.support.v7.widget.RecyclerView
            android:id="@+id/rv_licenses"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </LinearLayout>

</android.support.v7.widget.CardView>

我做错了什么?

您必须在库中添加compile 'com.android.support:design:23.4.0',并确保所有支持库版本与此23.4.0相同。

更新:

更改为

    compile "com.android.support:appcompat-v7:${google_support_library}"
    compile "com.android.support:design:${google_support_library}"
    compile "com.android.support:palette-v7:${google_support_library}"
    compile "com.android.support:cardview-v7:${google_support_library}"
    compile "com.android.support:recyclerview-v7:${google_support_library}"

    compile "com.android.support:appcompat-v7:23.4.0"
    compile "com.android.support:design:23.4.0"
    compile "com.android.support:palette-v7:23.4.0"
    compile "com.android.support:cardview-v7:23.4.0"
    compile "com.android.support:recyclerview-v7:23.4.0"

相关内容

  • 没有找到相关文章

最新更新