butterknife问题:错误:<identifier>预期

时间:2018-02-09 02:37:27

标签: android android-studio butterknife

你好我正在运行一个包含butterknife的项目,一切都很好但是我正在尝试编译它我在这段代码中得到了这个import butterknife.@BindView; import butterknife.ButterKnife; 这是我的gradle文件 请抓住它的战利品

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 27
        flavorDimensions "default"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

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




    /****************************
     * Change the given field below
     * *************************`**/

    productFlavors {
        wavie {
            applicationId "com.amiapp.wp.wavie" // change package name to something else before uploading to google play
            resValue "string", "app_name", "Wavie" // change app name to something else before uploading to google play
            buildConfigField "boolean", "FULL_VERSION", "false"
           resValue "string", "admob_full_ad", "" // Add your admob intertial unit id here
            manifestPlaceholders = [appIcon: "@mipmap/ic_launcher"]
            versionCode 1
            versionName "1"
        }

        waviepro {
            applicationId "com.amiapp.wp.wavie" // change package name to something else before uploading to google play
            resValue "string", "app_name", "Wavie Pro"  // change app name to something else before uploading to google play
            buildConfigField "boolean", "FULL_VERSION", "true"
           resValue "string", "admob_full_ad", "" // don't add any ad unit here because this is a paid version.
            manifestPlaceholders = [appIcon: "@mipmap/ic_launcher2"]
            versionCode 1
            versionName "1"
        }
    }


}

dependencies {
   final SUPPORT_LIB_VERSION = '27.0.2'
    final COLOR_PICKER_VERSION = '1.5'
    final BUTTER_KNIFE_VERSION = '8.4.0'

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

    compile 'com.google.android.gms:play-services-ads:11.8.0'
    //noinspection GradleCompatible
    compile "com.android.support:appcompat-v7:27.0.2"
    compile "com.larswerkman:HoloColorPicker:1.5"
    compile 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    compile project(':library')
}
apply plugin: 'com.jakewharton.butterknife'

和我的项目gradle

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        jcenter()
        google()


    }
}

任何帮助表示感谢,提前感谢Amine。 error

1 个答案:

答案 0 :(得分:1)

graader 3.0.1 for butterknife存在问题。使用9.0.0-SNAPSHOT

使用此

classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'

依赖

implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'