Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find symbol class on Butter Knife generated code

I'm trying to use butter knife but having trouble with the generated code. It's complaining with a namespace... I don't know why.

error: cannot find symbol class Detail

To simplify see all peaces, I take a print. Can you help me?

enter image description here

  • com.phormar.android.Detail namespace exists;
  • PessoaFragment are on com.phormar.android.Detail package as well.
like image 964
Tiago Gouvêa Avatar asked Apr 29 '16 14:04

Tiago Gouvêa


People also ask

Does @BindView complain of any error when importing butterknife?

Oddly enough, @BindView doesn't complain of any error. I am importing butterknife.BindView but have also tried importing butterknife.* to no avail. I've got version 8.4.0 of butterknife-compiler in the build.gradle file.

What is the meaning of cannot find symbol error?

The cannot find symbol error, also found under the names of symbol not found and cannot resolve symbol, is a Java compile-time error which emerges whenever there is an identifier in the source code which the compiler is unable to work out what it refers to.

How does the compiler use the identifiers in the source code?

When uses of these identifiers are encountered in the source code, the compiler looks them up in the symbol tables and relies on this information for things such as verifying that a variable has been declared, determining the scope of a variable, and verifying that an expression is semantically correct with type checking.

Why can't I find the symbol in Java?

The root cause for the cannot find symbol Java error can occasionally be found in some unexpected or obscure places. Such is the case with accidental semicolons that terminate a statement ahead of time (Fig. 5), or when object creation is attempted without a proper constructor invocation which has to have the new keyword (Fig. 6).


1 Answers

Make sure the version of the ButterKnife library matches the apt plugin version like this:

compile 'com.jakewharton:butterknife:8.5.1'

apt 'com.jakewharton:butterknife-compiler:8.5.1'

Please follow this link while adding ButterKnife to your build.gradle file:

https://github.com/JakeWharton/butterknife

like image 62
Sachin Rana Avatar answered Oct 19 '22 18:10

Sachin Rana