をバインドするときにnullを返します:butterKnife私はこのやろうとしているときにビュー(8.6.0)
...
public class LoginActivity extends AppCompatActivity {
@BindView(R.id.login_form) View loginForm;
...
loginForm
はnull
を得ています。私は他の答えに従おうとしましたが、何も働かなかった(例えばこれ)。私はまた、それがbutterKnife設定ページで言ったことを正確に行い、うまくいかなかった。私は間違って何をしていますか?
モジュールのGradle:
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "name"
minSdkVersion 22
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
プロジェクトのGradle:
あなたはまたmavenCentralを(追加のビューを使用する前に
ButterKnife.Bind(this)
を呼び出す必要がありますのonCreateで
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.6.0'
はあなたのonCreateメソッド、あなたがlogin_formを持つXMLを投稿してください。 –
この行をチェックしてください "ButterKnife.bind(this);" onCreateメソッドで。 –