ButterKnife 初次使用报错
ButterKnife first use error
在我遭受 findViewById
的折磨后,我决定使用 ButterKnife
但好消息告诉我你永远不会使用 ButterKnife
这是错误
@InjectView-annotated class incorrectly in Android framework package.
为什么?我的错误在哪里? gradle dependency
错了吗?
我看到了 this post 但它对我没有帮助
gradle 文件(模块)
apply plugin: 'com.neenbedankt.android-apt'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
dependencies {
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
这一行的错误
@BindView(R.id.button_birth_date)
private Button buttonBirthDate;
和其他使用@BindView
的成员变量(视图)
如果你使用最后一个 Butterknife,你确实使用 Butterknife.bind(this) 而不是 Butterknife.inject(this),对于视图使用 @Bind(R.id.idview) 而不是 @InjectView(R.id.idview).
参见 documentation
编辑:更改你的包名,你不能'使用android.*或java.*,Jake Wharton answer solution
杰克·沃顿,
异常说明了一切:
@InjectView-annotated class incorrectly in Android framework package.
您的 class 在 Android 框架包中,android.。应用程序不应将 android. 或 java.* 包用于其代码。 ButterKnife 会急切地拒绝这些包裹。
更改您的包名称。 android.alcode.com.material 到 something.alcode.com.material
您的包裹名称不能包含 android
单词
so make sure that your application package
name doesn't contain
android word
on it
在我遭受 findViewById
的折磨后,我决定使用 ButterKnife
但好消息告诉我你永远不会使用 ButterKnife
这是错误
@InjectView-annotated class incorrectly in Android framework package.
为什么?我的错误在哪里? gradle dependency
错了吗?
我看到了 this post 但它对我没有帮助
gradle 文件(模块)
apply plugin: 'com.neenbedankt.android-apt'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
dependencies {
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
这一行的错误
@BindView(R.id.button_birth_date)
private Button buttonBirthDate;
和其他使用@BindView
的成员变量(视图)如果你使用最后一个 Butterknife,你确实使用 Butterknife.bind(this) 而不是 Butterknife.inject(this),对于视图使用 @Bind(R.id.idview) 而不是 @InjectView(R.id.idview). 参见 documentation
编辑:更改你的包名,你不能'使用android.*或java.*,Jake Wharton answer solution
杰克·沃顿, 异常说明了一切:
@InjectView-annotated class incorrectly in Android framework package.
您的 class 在 Android 框架包中,android.。应用程序不应将 android. 或 java.* 包用于其代码。 ButterKnife 会急切地拒绝这些包裹。
更改您的包名称。 android.alcode.com.material 到 something.alcode.com.material
您的包裹名称不能包含 android
单词
so make sure that
your application package
name doesn't containandroid word
on it