The import butterknife.InjectView cannot be resolved

前端 未结 5 1264
没有蜡笔的小新
没有蜡笔的小新 2020-12-29 10:37

I am trying to use this library project, so I tried to run the sample application (in /app/source/main/ in the Github link), and in MainActivity.java

相关标签:
5条回答
  • 2020-12-29 10:47

    @InjectView is no more available and is replaced by @BindView. We will have to import Butterknife dependencies to use the annotations.

    0 讨论(0)
  • 2020-12-29 10:48

    Change ButterKnife.inject(this); to ButterKnife.bind(this);

    0 讨论(0)
  • 2020-12-29 10:56

    Latest version has bind instead of InjectView. Version before that, uses ButterKnife.inject(this) to inject view. Also, Eclipse is not supported anymore, start using Android Studio.

    0 讨论(0)
  • 2020-12-29 11:02

    Try add:implementation 'com.jakewharton:butterknife:6.1.0' in your build.gradle

    0 讨论(0)
  • 2020-12-29 11:04

    Credit to @Sharj for answering first.

    The Butterknife 7.0.0 release included the breaking change of renaming of the annotation verbs. This is highlighted in the changelog and reflected in the website.

    Version 7.0.0 *(2015-06-27)*
    ----------------------------
    
     * `@Bind` replaces `@InjectView` and `@InjectViews`.
     * `ButterKnife.bind` and `ButterKnife.unbind` replaces `ButterKnife.inject` 
        and `ButterKnife.reset`, respectively.
    ...
    

    https://github.com/JakeWharton/butterknife/blob/f65dc849d80f6761d1b4a475626c568b2de883d9/CHANGELOG.md

    0 讨论(0)
提交回复
热议问题