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

Joyce Chidiadi
Joyce Chidiadi
1,867 Points

@ButterKnife (BIndView) errors on my code

I have followed the video step by step for the ButterKnife method, but I get these errors on my code and for sure doesn't allow my app to run.

@BindView(R.id.timeLabel) TextView TimeLabel; @BindView(R.id.temperatureLabel) TextView TemperatureLabel; @BindView(R.id.humidityValue) TextView HumidityLabel; @BindView(R.id.precipValue) TextView PrecipValue; @BindView(R.id.summaryLabel) TextView SummaryLabel; @BindView(R.id.iconImageView) TextView IconImageView; The ((R.id.timeLabel) part in all these codes are highlighted and I get this error showing, "Error:(36, 19) error: cannot find symbol method value()" when I run the app.

What could I be doing wrong?

Below is my XML code;

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="joycechidiadi.com.weatherappy.MainActivity" android:background="#ffbb33">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@drawable/degree"
    android:layout_alignTop="@+id/temperatureLabel"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_marginRight="61dp"
    android:layout_marginEnd="61dp"
    android:layout_marginTop="25dp"
    android:id="@+id/degreeimageView"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textPersonName"
    android:text="   100"
    android:ems="10"
    android:id="@+id/temperatureLabel"
    android:textColor="@android:color/white"
    android:textSize="100sp"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textPersonName"
    android:text="At 5:00PM, it will be"
    android:ems="10"
    android:layout_above="@+id/degreeimageView"
    android:layout_centerHorizontal="true"
    android:id="@+id/timeLabel"
    android:textColor="#80ffffff"
    android:textSize="18sp"/>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@drawable/cloudy_night"
    android:layout_alignBottom="@+id/locationLabel"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:id="@+id/iconImageView"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textPersonName"
    android:text="   Calgary AB, Canada"
    android:ems="10"
    android:id="@+id/locationLabel"
    android:textColor="@android:color/white"
    android:textSize="24sp"
    android:layout_marginBottom="77dp"
    android:layout_above="@+id/timeLabel"
    android:layout_toRightOf="@+id/iconImageView"
    android:layout_toEndOf="@+id/iconImageView"/>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/temperatureLabel"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="10dp">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_toRightOf="@+id/humidityLabel">

        <TextView
            android:text="HUMIDITY"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/humidityLabel"
            android:textColor="#80ffffff"/>

        <TextView
            android:text="0.88"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/humidityValue"
            android:textColor="@android:color/white"
            android:textSize="24sp"/>
    </LinearLayout>
</LinearLayout>

<TextView
    android:text="RAIN/SNOW?"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/temperatureLabel"
    android:layout_toEndOf="@+id/locationLabel"
    android:id="@+id/precipLabel"
    android:layout_alignWithParentIfMissing="false"
    android:textColor="#80ffffff"
    android:layout_alignBottom="@+id/linearLayout3"
    android:textSize="10sp"
    android:layout_alignLeft="@+id/precipValue"
    android:layout_alignStart="@+id/precipValue"
    android:layout_toRightOf="@+id/locationLabel"/>

<TextView
    android:text="100%"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/precipLabel"
    android:id="@+id/precipValue"
    android:textColor="@android:color/white"
    android:textSize="24sp"
    android:gravity="center_horizontal|fill_horizontal"
    android:layout_toRightOf="@+id/timeLabel"
    android:layout_toEndOf="@+id/timeLabel"/>

<TextView
    android:text="Rainy with a chance of hailstone"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="77dp"
    android:id="@+id/summaryLabel"
    android:textSize="18sp"
    android:textColor="@android:color/white"
    android:gravity="center_horizontal"/>

</RelativeLayout>

Seth Kroger
Seth Kroger
56,413 Points

What about your build.gradle (App)? And do you have the correct import statement for the BindView annotation?

4 Answers

Joyce Chidiadi
Joyce Chidiadi
1,867 Points

I can only see "import butterknife. Butterknife;" There is no import statement for Bind View showing up here.

Do you mean the Grade build messages?

Joyce Chidiadi
Joyce Chidiadi
1,867 Points

Hi Seth, Here is the build.gradle(app) Scripts: apply plugin: 'com.android.application'

android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "joycechidiadi.com.weatherappy" minSdkVersion 14 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }

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.0' compile 'com.squareup.okhttp3:okhttp:3.5.0' compile 'com.jakewharton:butterknife:8.4.0' testCompile 'junit:junit:4.12' compile 'com.google.android.gms:play-services-appindexing:8.4.0' }

Seth Kroger
Seth Kroger
56,413 Points

You're missing one of the lines needed in the dependency block Add it, re-sync gradle and try to auto-import @BindView:

dependencies {
  compile 'com.jakewharton:butterknife:8.4.0'
  annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
}

https://github.com/JakeWharton/butterknife#download Both are needed for the current version to work.

Joyce Chidiadi
Joyce Chidiadi
1,867 Points

I have just added the recommended line; annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

Have synced the Gradle many times but the error messages still persist. I t still says Cannot find the method for all the parameters in @BindView piece of code. What next, please? Thank you for your help.