我正在使用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')
}
提前感谢。非常感谢
答案 0 :(得分:1)
最近将Android支持库升级到最新版本后出现了同样的问题。我的解决方案是从我的项目中删除所有支持库依赖项,然后从支持设计库开始重新添加它们,然后再添加AppCompat等。设计库依赖于最新的AppCompat,尽管其他答案不是替代AppCompat。
我认为问题归结为版本的冲突,或者某些东西卡在缓存中。
答案 1 :(得分:0)
尝试从依赖项中删除appCompat库,只需使用它所支持的支持设计库来替换它。