java - 无法解析符号 'ButterKnife'

标签 java android android-studio butterknife

我正在尝试使用 butterknife 。但我收到错误“无法解析符号'**ButterKnife'”。 我尝试手动导入 butterknife.ButterKnife 但出现了相同的错误 我修改了 gradle 并添加了这些行: 在项目级别...

dependencies {
              classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
             }

在模块级别...

apply plugin: 'com.android.application' 
apply plugin: 'android-apt'

dependencies { 

   compile 'com.jakewharton:butterknife-compiler:8.5.1'
   apt 'com.jakewharton:butterknife-compiler:8.5.1' 

}

我该怎么办? 提前致谢 。 这是我收到错误的代码的屏幕截图 link for the screenshot

最佳答案

apply plugin: 'com.android.application'
android {
    compileSdkVersion XX
    buildToolsVersion "XX.0.0"
    defaultConfig {
        applicationId "com.xxxxx.xxx"
        minSdkVersion xx
        targetSdkVersion xx
        versionCode x
        versionName "x.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}


apply plugin: 'com.neenbedankt.android-apt'


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.1'
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.code.findbugs:jsr305:2.0.1'
    compile 'com.android.support:design:25.1.1'
    compile 'com.jakewharton:butterknife:8.0.1'

    apt 'com.jakewharton:butterknife-compiler:8.0.1'
    testCompile 'junit:junit:4.12'
}

关于java - 无法解析符号 'ButterKnife',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42155896/

相关文章:

java - Java 什么时候有了 JIT 编译器?

java - 5 秒后加载新 Activity

android - 多进程应用程序中的 Firebase 分析事件日志记录

java - 无法初始化 native 平台。在 Jenkins

java - 任务完成后如何显示Toast?

java - 安卓 JUnit : How to have an exception cause a test case to pass (@Test annotation)

java - 缓存图像和数据时应该使用内部存储还是外部存储?

android - 在 actionbar-sherlock 中自定义主题不起作用

Android Studio 创建示例游戏时出错

java - Maven找不到java路径