Search code examples
javaandroidbutterknife

symbol class Bind cannot be found while building project


hi devs I'am having an issue with this code.

build Module is like:

   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.4.0"

        compile project(':library')
    }

when I'm trying to run it this error shows:

Error:(17, 19) error: cannot find symbol class Bind at specific java files

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Color picker
 */
public class ColorPickerDialogFragment extends DialogFragment {

    public static final String KEY_INDEX = "INDEX";
    public static final String KEY_COLOR = "COLOR";
    @Bind(R.id.picker)
    ColorPicker colorPicker;
    @Bind(R.id.svbar)
    SVBar svBar;
    @Bind(R.id.btn_save)
    Button btnSave;

Solution

  • For ButterKnife 8.4.0, you need to use BindView:

    class ExampleActivity extends Activity {
      @BindView(R.id.user) EditText username;
      @BindView(R.id.pass) EditText password;
    
      @BindString(R.string.login_error) String loginErrorMessage;
    
      @OnClick(R.id.submit) void submit() {
        // TODO call server...
      }
    
      @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_activity);
        ButterKnife.bind(this);
        // TODO Use fields...
      }
    }