我正在使用Drawer布局,并在更新我的应用程序以构建版本23.0.1之后,面临以下异常

java.lang.NoSuchMethodError: No static method getLayoutDirection(Landroid/graphics/drawable/Drawable;)I in class Landroid/support/v4/graphics/drawable/DrawableCompat


我的抽屉布局.xml文件如下

 <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


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

        <include
            layout="@layout/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <ViewStub
            android:id="@+id/activity_main_content_stub"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"/>
    </LinearLayout>


    <!-- The navigation drawer -->
    <!-- The navigation drawer -->
    <android.support.design.widget.NavigationView
        android:id="@+id/navView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="left">
    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="260dp"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:background="@color/nav_drawer_bg_color"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:listSelector="@color/transparent"
        android:dividerHeight="0dp"/>
    </android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>




</android.support.v4.widget.DrawerLayout>


并为我的应用程序构建.gradle

    apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.1'

    defaultConfig {
        applicationId "com.file.operator.help"
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/dependencies.txt'
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
    }
}
configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.android.gms:play-services:7.8.0'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
    compile 'com.google.zxing:core:3.2.0'
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile project(':LicensePlateSannerLibrary')
    compile project(':cardflight-sdk')`enter code here`
    compile files('libs/CWAC-SackOfViewsAdapter.jar')
    compile files('libs/mint-4.0.7.jar')
    compile files('libs/universal-image-loader-1.9.0.jar')
}


在此先感谢您的帮助。

最佳答案

将Android支持库升级到最新版本后,最近也遇到了同样的问题。我的解决方案是从项目中删除所有支持库依赖项,然后从支持设计库,然后是AppCompat等开始重新添加它们。设计库对最新的AppCompat具有依赖项,尽管其他答案不是AppCompat的替代品。

我想问题可能出在版本冲突,或者某些东西卡在缓存中。

10-07 19:21
查看更多