Android错误膨胀类android.support.design.widget.CollapsingToolbarLayout

时间:2016-07-22 04:57:32

标签: android

在我的应用程序中,我想使用这个支持小部件但是我收到错误:

Error inflating class android.support.design.widget.CollapsingToolbarLayout

经过更多googlenig和SF搜索后,我找不到任何解决方案来解决这个问题。我不知道为什么会出现此错误,因为它与其他用法相似

我的布局:

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    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"
        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="65dp"
            android:background="@drawable/toolbar_background"
            android:titleTextColor="#ffffff"/>

        <com.sloydev.collapsingavatartoolbar.CollapsingAvatarToolbar
            android:id="@+id/stuff_container"
            android:layout_width="match_parent"
            android:layout_height="65dp">

        </com.sloydev.collapsingavatartoolbar.CollapsingAvatarToolbar>
    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

</android.support.design.widget.CoordinatorLayout>

我的Gradle:

ext {
    supportLibVersion = '23.4.0'
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile ("com.android.support:support-v4:${supportLibVersion}"){
        force = true;
    }
    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"
    compile "com.android.support:recyclerview-v7:${supportLibVersion}"
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.squareup.okhttp3:okhttp:3.3.1'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.5'
    compile('io.socket:socket.io-client:0.7.0') {
        // excluding org.json which is provided by Android
        exclude group: "org.json", module: "json"
    }
    compile('com.squareup.retrofit2:retrofit:2.0.2') {
        exclude module: 'okhttp'
    }
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
    compile 'com.squareup.okhttp3:okhttp:3.3.1'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.github.devlight.navigationtabbar:library:+'
    compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2'
    compile 'com.balysv:material-ripple:1.0.2'
    compile 'com.github.traex.rippleeffect:library:1.3'
    compile 'com.github.chyrta:AndroidOnboarder:+'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.github.lamydev:android-notification:3.0'
    compile 'com.klinkerapps:sliding-activity:1.3.2'
    compile 'com.koushikdutta.ion:ion:2.+'
    compile 'com.bugsnag:bugsnag-android:+'
    compile 'com.github.liuguangqiang.swipeback:library:1.0.2@aar'
    compile 'com.github.justzak:dilatingdotsprogressbar:1.0.1'
    compile 'com.github.Kennyc1012:BottomSheet:2.1.2'
    compile 'com.yalantis:flipviewpager:1.0.0'
    compile 'com.github.techery:ProperRatingBar:0.+'
    compile 'com.wunderlist:sliding-layer:1.2.5'
    compile 'com.facebook.rebound:rebound:0.3.8'
    compile 'com.tumblr:backboard:0.1.0'
    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
    compile 'com.makeramen:roundedimageview:2.2.1'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.easing:library:1.0.1@aar'
    compile 'com.daimajia.androidanimations:library:1.1.3@aar'
    compile 'com.jaredrummler:android-device-names:1.0.9'
    compile 'org.sufficientlysecure:html-textview:1.6'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
    compile 'com.github.ksoichiro:android-observablescrollview:1.5.2'
    compile 'com.kogitune:pre-lollipop-activity-transition:1.3.0'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.flyco.roundview:FlycoRoundView_Lib:1.1.4@aar'
    compile 'com.daimajia.slider:library:1.1.5@aar'
    compile 'com.squareup.picasso:picasso:2.3.2'
    compile 'com.mikhaellopez:circularimageview:3.0.2'
    compile 'com.github.traex.rippleeffect:library:1.3'
    compile 'com.alexvasilkov:foldable-layout:1.2.0'
    compile 'com.alexvasilkov:android-commons:1.2.4'
    compile 'com.mikhaellopez:circularfillableloaders:1.2.0'
    compile 'cat.ereza:customactivityoncrash:1.5.0'
    compile 'jp.wasabeef:glide-transformations:2.0.1'
    compile 'com.sloydev:collapsingavatartoolbar:1.0.0'
    compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
    compile 'com.github.hotchemi:permissionsdispatcher:2.0.7'
    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.0.7'
    compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
        exclude group: 'com.google.android', module: 'support-v4'
    }
    compile('com.github.ozodrukh:CircularReveal:2.0.1@aar') {
        transitive = true;
    }
    compile project(':lib-searchview')
}

完整堆栈错误:

07-22 09:22:01.206 15932-15932/ir.pishguy.signalpresentationproject E/CustomActivityOnCrash:App has crashed,executing CustomActivityOnCrash's UncaughtExceptionHandler
        java.lang.RuntimeException:Unable to start activity ComponentInfo{ir.pishguy.signalpresentationproject/ir.pishguy.signalpresentationproject.Activities.ActivityMain}:android.view.InflateException:Binary XML file line #21:Binary XML file line #7:Error inflating

class android.support.design.widget.CollapsingToolbarLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2464)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
        at android.app.ActivityThread.access$900(ActivityThread.java:154)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:234)
        at android.app.ActivityThread.main(ActivityThread.java:5526)
        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 #21:Binary XML file line #7: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.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at ir.pishguy.signalpresentationproject.Activities.ActivityMain.onCreate(ActivityMain.java:52)
        at android.app.Activity.performCreate(Activity.java:6285)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524) 
        at android.app.ActivityThread.access$900(ActivityThread.java:154) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:234) 
        at android.app.ActivityThread.main(ActivityThread.java:5526) 
        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 #7: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.parseInclude(LayoutInflater.java:971)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:831)
        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.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.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at ir.pishguy.signalpresentationproject.Activities.ActivityMain.onCreate(ActivityMain.java:52) 
        at android.app.Activity.performCreate(Activity.java:6285) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524) 
        at android.app.ActivityThread.access$900(ActivityThread.java:154) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:234) 
        at android.app.ActivityThread.main(ActivityThread.java:5526) 
        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.parseInclude(LayoutInflater.java:971) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:831) 
        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.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.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at ir.pishguy.signalpresentationproject.Activities.ActivityMain.onCreate(ActivityMain.java:52) 
        at android.app.Activity.performCreate(Activity.java:6285) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524) 
        at android.app.ActivityThread.access$900(ActivityThread.java:154) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:234) 
        at android.app.ActivityThread.main(ActivityThread.java:5526) 
        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/ir.pishguy.signalpresentationproject/files/instant-run/dex/slice-com.android.support-support-v4-24.0.0_4b43aba066322bf0426e63e87ab20c7abe086ec0-classes.dex)
        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.parseInclude(LayoutInflater.java:971) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:831) 
        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.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.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at ir.pishguy.signalpresentationproject.Activities.ActivityMain.onCreate(ActivityMain.java:52) 
        at android.app.Activity.performCreate(Activity.java:6285) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524) 
        at android.app.ActivityThread.access$900(ActivityThread.java:154) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:234) 
        at android.app.ActivityThread.main(ActivityThread.java:5526) 
        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) 

1 个答案:

答案 0 :(得分:1)

尝试在清单中添加android:theme="@style/Theme.AppCompat.Light.NoActionBar"

CollapsingToolbarLayout需要appCompat v7支持