NoSuchFieldError:没有类型的静态字段CoordinatorLayout_LayoutParams

时间:2016-11-08 13:15:17

标签: android

我不知道为什么会收到此错误消息:

Process: *.*.*, PID: 24384
                                                                        java.lang.NoSuchFieldError: No static field CoordinatorLayout_LayoutParams of type [I in class Landroid/support/design/R$styleable; or its superclasses (declaration of 'android.support.design.R$styleable' appears in /data/app/*.*.*-2/base.apk)
                                                                            at android.support.design.widget.CoordinatorLayout$LayoutParams.<init>(CoordinatorLayout.java:2274)
                                                                            at android.support.design.widget.CoordinatorLayout.generateLayoutParams(CoordinatorLayout.java:1439)
                                                                            at android.support.design.widget.CoordinatorLayout.generateLayoutParams(CoordinatorLayout.java:92)

我的布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white">

    <ListView
        android:id="@+id/listview_diary"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:divider="@null"
        android:dividerHeight="16dp"
        android:fadingEdge="none"
        android:fitsSystemWindows="true"
        android:padding="12dp"
        android:scrollbars="none"
        android:background="@android:color/white"/>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_add_diary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_margin="16dp"
        android:clickable="true"
        android:padding="8dp"
        android:src="@mipmap/ic_add"
        app:backgroundTint="@color/colorPrimary"
        app:borderWidth="0dp"/>

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

我的朋友:

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"

    defaultConfig {
        applicationId "*.*.*"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        jackOptions {
            enabled true
        }
        // Enabling multidex support.
        multiDexEnabled true
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    dexOptions {
        javaMaxHeapSize "2g"
        incremental true
        preDexLibraries = false
    }
}
repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url 'https://raw.github.com/felipecsl/m2repository/master' }
    //  maven { url "https://jitpack.io" }
    mavenCentral()

}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.github.florent37:materialviewpager:1.2.0@aar') {
        transitive = true
    }
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.0.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:cardview-v7:24.0.0'
    compile 'com.android.support:support-v4:24.0.0'
    ...

1 个答案:

答案 0 :(得分:1)

只需更新以下插件的相同版本

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:support-v4:24.0.0'
像这样

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'