What i am doing::
- I am trying to run butter knife library for my simple project
- I have followed all the steps in documentation, but still i am getting log errors
- How can i resolve this, am i missing any step
- I have also added the jar in libs folder
MainActivity.java
package com.example.butterknife;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
public class MainActivity extends Activity {
@InjectView(R.id.txtID) TextView title;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
title.setText("Hello Everyone !!");
}
}
Log::
04-15 11:50:57.845: E/AndroidRuntime(913): FATAL EXCEPTION: main
04-15 11:50:57.845: E/AndroidRuntime(913): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.butterknife/com.example.butterknife.MainActivity}: java.lang.NullPointerException
04-15 11:50:57.845: E/AndroidRuntime(913): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
04-15 11:50:57.845: E/AndroidRuntime(913): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
04-15 11:50:57.845: E/AndroidRuntime(913): at android.app.ActivityThread.access$600(ActivityThread.java:122)
04-15 11:50:57.845: E/AndroidRuntime(913): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
04-15 11:50:57.845: E/AndroidRuntime(913): at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 11:50:57.845: E/AndroidRuntime(913): at android.os.Looper.loop(Looper.java:137)
04-15 11:50:57.845: E/AndroidRuntime(913): at android.app.ActivityThread.main(ActivityThread.java:4340)
04-15 11:50:57.845: E/AndroidRuntime(913): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 11:50:57.845: E/AndroidRuntime(913): at java.lang.reflect.Method.invoke(Method.java:511)
04-15 11:50:57.845: E/AndroidRuntime(913): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-15 11:50:57.845: E/AndroidRuntime(913): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-15 11:50:57.845: E/AndroidRuntime(913): at dalvik.system.NativeStart.main(Native Method)
04-15 11:50:57.845: E/AndroidRuntime(913): Caused by: java.lang.NullPointerException
04-15 11:50:57.845: E/AndroidRuntime(913): at com.example.butterknife.MainActivity.onCreate(MainActivity.java:19)
04-15 11:50:57.845: E/AndroidRuntime(913): at android.app.Activity.performCreate(Activity.java:4465)
04-15 11:50:57.845: E/AndroidRuntime(913): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-15 11:50:57.845: E/AndroidRuntime(913): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
04-15 11:50:57.845: E/AndroidRuntime(913): ... 11 more
04-15 11:51:06.722: I/Process(913): Sending signal. PID: 913 SIG: 9
title
is null, it hasn't been injected with anything. – Cynara