构建项目时无法找到符号类绑定

时间:2018-01-27 16:58:51

标签: java android butterknife

嗨,开发者我遇到了这段代码的问题。

构建模块就像:

   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')
    }

当我试图运行它时,此错误显示:

  

错误:(17,19)错误:找不到特定java的符号类绑定   文件

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;

1 个答案:

答案 0 :(得分:0)

对于ButterKnife 8.4.0 ,您需要使用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...
  }
}