首页 > 解决方案 > 关于我的android项目上的静态接口方法的错误

问题描述

我正在制作一个连接到星球大战 api 的项目,获取 json 对象回复并通过 recycleView(简而言之)在我的视图上呈现它们。但是,我通过我的 gradle 文件(这里是完整的)在构建项目上遇到错误:

apply plugin: 'com.android.application'

android {

    // Configure only for each module that uses Java 8
    // language features (either in its source code or
    // through dependencies).
    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    compileSdkVersion 28
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "com.juangm.bottomnavigationmvp"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])


    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test:rules:1.1.0'

    compile 'com.android.support:appcompat-v7:28.3.1'
    compile 'com.android.support:cardview-v7:28.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.1.3'
    compile 'com.android.support:design:28.3.1'
    compile 'com.android.support:support-v4:28.3.1'
    testCompile 'junit:junit:4.12'
    compile 'com.jakewharton:butterknife:8.3.2'
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.5'
    implementation 'com.jakewharton:butterknife-compiler:8.1.0'
    compile 'com.squareup.retrofit2:retrofit:2.5.0'
    compile 'com.squareup.retrofit2:converter-gson:2.5.0'
    compile 'com.squareup.okhttp3:okhttp:3.12.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
    compile 'com.android.support:support-annotations:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.1.1'
}

我得到的错误:**静态接口方法仅支持从 Android N (--min-api 24) 开始: void butterknife.Unbinder.lambda$static$0() 堆栈跟踪:**

如您所见,我已经在 gradle 上添加了 JAVA.version 1_8 的编译选项,但似乎并没有解决问题。

任何帮助表示赞赏...

标签: androidstaticbutterknife

解决方案


请务必将 Biutterknife 版本更新为最新版本,如下所示并同步。观察过黄油刀

implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'

Android Studio 应更新至 4.0 版,以根据 Android 文档使用 Java 8 Desugaring。Java 8 语言特性


推荐阅读