使用ButterKnife碰到的问题

  1. Caused by: java.lang.IllegalStateException
 Caused by: java.lang.IllegalStateException: Required view 'toolbar' with ID 2131492999 for field 'toolbar' was not found. If this view is optional add '@Nullable' annotation.
at butterknife.ButterKnife$Finder.findRequiredView(ButterKnife.java:140)
at qiufeng.android.base.BaseActivity$$ViewBinder.bind(BaseActivity$$ViewBinder.java:11)
at qiufeng.android.ui.MainActivity$$ViewBinder.bind(MainActivity$$ViewBinder.java:9)
at qiufeng.android.ui.MainActivity$$ViewBinder.bind(MainActivity$$ViewBinder.java:7)
at butterknife.ButterKnife.bind(ButterKnife.java:319)
at butterknife.ButterKnife.bind(ButterKnife.java:237) 
at qiufeng.android.base.BaseActivity.onCreate(BaseActivity.java:37) 
at android.app.Activity.performCreate(Activity.java:5231) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5001) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
at dalvik.system.NativeStart.main(Native Method) 

造成这个问题的原因是在SetContentView之前就写了ButterKnife(this)
正确写法应该 是在setContentView之后才写

你可能感兴趣的:(使用ButterKnife碰到的问题)