I am using butterknife:8.8.1 like mentioned here
My Project level gradle is like below
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
...
}
}
apply plugin: 'com.jakewharton.butterknife'
Module Level gradle like below
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'
dependencies {
...
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
Activity file is like below
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.details);
ButterKnife.bind(this);
ButterKnife.setDebug(true);
}
xml file is like below
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/device_info_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/sensor_settings_background">
....
<RelativeLayout
android:id="@+id/container_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:background="@color/settings_background">
<Button
android:id="@+id/connect_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_alignParentLeft="true"
android:background="@drawable/selector"
android:text="@string/connect"
android:textColor="@color/red"
android:textStyle="italic" />
<Button
android:id="@+id/register_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp"
android:text="@string/register"
android:visibility="gone" />
<Button
android:id="@+id/unregister_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_alignParentRight="true"
android:background="@drawable/selector"
android:text="@string/unregister"
android:textColor="@color/red"
android:textStyle="italic"
android:visibility="gone"
tools:visibility="visible" />
</RelativeLayout>
</RelativeLayout>
After compilation R2.java file is getting generated with Resource Ids
and
images.
I am getting NullPointerException
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setClickable(boolean)' on a null object reference
Can some one help me understand what I am doing wrong here.
I do experience the same issue. Changed Button to AppCompatButton, issue resolved.