The solution to using butterknife cannot inject view

Source: Internet
Author: User

When using Butterknife for Android development, it is found that inject, such as tvinfo, is always null.

@InjectView (r.id.textview1info) TextView tvinfo; @Overridepublic void OnCreate (Bundle savedinstancestate) { Super.oncreate (savedinstancestate); GetWindow (). Requestfeature (Window.feature_no_title); Setcontentview ( R.layout.main); Butterknife.inject (this); Tvinfo.settext ("test");//Tvinfo is null.}

Later on the official network to find a solution, as follows:

Http://jakewharton.github.io/butterknife/ide-eclipse.html

Eclipse Configuration
  1. Right click to your project in the package Explorer. Head to Java compiler→annotation processing and check "Enable Project specific Settings".

    Ensure the other annotation processing settings is the same as shown below:

  2. Expand the Annotation processing section and select Factory Path. Check "Enable Project specific Settings" and then click "Add JARs ...". Navigate to the project ' s libs/ folder and select the Butter knife jar.

  3. Click "OK" to save the new settings. Eclipse would ask you to rebuild your project to which you should click "Yes"
  4. Make sure, the .apt_generated/ folder is in your project root. It should contain files like YOURACTIVITY$$ViewInjector.java . If These files is not present trigger a clean build by selected Project→clean. This folder and files should not being checked into revision control.
  5. Lastly, under "Java Compiler", make sure, the Compiler compliance level are set to Java version 1 .6 at minimum.

The solution to using butterknife cannot inject view

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.