eclipse 导入的butterknife.InjectView 无法解析
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31531475/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The import butterknife.InjectView cannot be resolved
提问by Solace
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
, I am getting the error on the import
我正在尝试使用这个库项目,所以我尝试运行示例应用程序(在/app/source/main/
Github 链接中),并且在MainActivity.java
导入时出现错误
import butterknife.InjectView;
and also in MainActivity.java
and VerticalLinearRecyclerViewSample.java
, at every occurance of @InjectView(...)
annotation, I get the following error:
并且在MainActivity.java
and 中VerticalLinearRecyclerViewSample.java
,每次出现@InjectView(...)
注释时,我都会收到以下错误:
InjectView cannot be resolved to a type
So what should I do about this?
那么我该怎么办呢?
WHAT I TRIED:
我试过的:
I have seen this question. Didn't work for me, left a comment there.
我见过这个问题。对我不起作用,在那里留下评论。
I have followed these steps to include the Butter Knife librarytill Step#3. About Step#4, "Make sure that the .apt_generated/ folder is in your project root..."- this project does not have any folder named .apt-generated
or something in the project root folder.
我已经按照这些步骤包含了 Butter Knife 库,直到第 3 步。关于第 4 步,“确保 .apt_generated/ 文件夹位于您的项目根目录中...”- 该项目.apt-generated
在项目根文件夹中没有任何命名的文件夹或其他内容。
Note:I actually use Eclipse, and the project on Github is for Android Studio, so I created a new project in eclipse and copied individual files from the downloaded Android Studio project. I hope this does not made a difference.
注意:我实际使用的是Eclipse,Github上的项目是针对Android Studio的,所以我在eclipse中新建了一个项目,从下载的Android Studio项目中复制了单个文件。我希望这不会产生影响。
回答by Derek
Credit to @Sharj for answering first.
感谢@Sharj 首先回答。
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.
Butterknife 7.0.0 版本包括对注释动词重命名的重大更改。这在变更日志中突出显示并反映在网站中。
Version 7.0.0 *(2015-06-27)*
----------------------------
* `@Bind` replaces `@InjectView` and `@InjectViews`.
* `ButterKnife.bind` and `ButterKnife.unbind` replaces `ButterKnife.inject`
and `ButterKnife.reset`, respectively.
...
回答by Sharj
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.
最新版本有bind
而不是InjectView
. 之前的版本,用于ButterKnife.inject(this)
注入视图。此外,不再支持 Eclipse,请开始使用 Android Studio。
回答by Manideep
@InjectView
is no more available and is replaced by @BindView
. We will have to import Butterknife
dependencies to use the annotations
.
@InjectView
不再可用并由 代替@BindView
。我们必须导入Butterknife
依赖项才能使用annotations
.
回答by paulfranco
Change ButterKnife.inject(this); to ButterKnife.bind(this);
更改 ButterKnife.inject(this); 到 ButterKnife.bind(this);
回答by Youn Tivoli
Try add:implementation 'com.jakewharton:butterknife:6.1.0'
in your build.gradle
尝试添加:implementation 'com.jakewharton:butterknife:6.1.0'
在您的build.gradle