Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Weather App (2015) Hooking Up the Model to the View Using Butter Knife for Views

@Bind - Cannot resolve symbol BindView in Butterknife

I attempted to download Butterknife by following the instructions in the GitHub ReadMe, and later by following some of the examples here in the Community postings. The instructions are not hard to follow, yet my @BindView annotation was always underlined in red, revealing an error. Trying to run my program resulted in an error of: Cannot resolve symbol BindView.

I was able to work around the issue by manually adding "import butterknife.BindView;" to my import statements, but I'd like to know why I'm having this problem for future reference, Any assistance would be greatly appreciated. Thanks!

build.gradle (Project: Stormy)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle (Module:app)

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


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.mypackagemanehere.stormy"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.jakewharton:butterknife:8.4.0'
    apt 'com.jakewharton:butterknife-compiler:8.4.0'

}

1 Answer

I guess you forgot: apply plugin: 'android-apt' above the dependecies {} in build.gradle(Module: app)

https://github.com/JakeWharton/butterknife#download.

You may also look at this: https://teamtreehouse.com/community/plugin-with-id-androidapt-not-found. That's where I found my answer.