Solvedbutterknife ButterKnife generates ViewBinding class with wrong resource ID

I am using a 3rd-party library in our project, and compilation works fine, but the app crashes when it starts up. I looked at the logcat and generate source code, it seems the generated source code has the wrong resource ID.

For example, the source file is

class HomeActivity ... {
    @BindView( AppModeTransitionLayout modeTransitionLayout;

    protected void onCreate(@Nullable Bundle savedInstanceState) {


The generated HomeActivity_ViewBinding class has

  public HomeActivity_ViewBinding(T target, View source) { = target;

    target.modeTransitionLayout = Utils.findRequiredViewAsType(source,, "field 'modeTransitionLayout'", AppModeTransitionLayout.class);
  } is a different resource ID, and I'd assume here should use

At the runtime I get an exception says
java.lang.IllegalStateException: Required view 'infant_description_text' with ID 2131822441 for field 'modeTransitionLayout' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) annotation.

We are using ButterKnife 8.4.0.

Any help is highly appreciated!

30 Answers

✔️Accepted Answer

i am seeing this issue with 8.8.1 too. especially after adding a new xml layout via copy and paste, and then renaming some ids (not refactoring)

The only secure way is to delete the app/build folder and rebuild the project

Other Answers:

Same problem in my project. I have tested with various versions of ButterKnife. Version 8.5.1 works fine. Version 8.6.0 and all above stable produces this error. Cleaning project not resolves this problem.

@JakeWharton I fixed my issue, for your reference, here is the build config I changed:

Before (generated code with wrong resource ID):

  • library 'core' depends on 3rd-party library
  • library 'lib' depends on 'core' and 3rd-party library
  • module 'app' depends on 'lib'

I removed the dependency from 'core' to 3rd-party library and butterknife works properly.

Our of curiosity, is there a way to invoke butterknife from command line for debugging?

we're still seeing this problem, sounds like a legit butterknife bug. @engian i'd recommend reopening

Related Issues:

butterknife 依赖最新版的9.0.0-rc2运行报错
@moneeWong Add this to your build.gradle Error: Static interface methods are only supported starting...
butterknife Android X support
I've recently attempted to upgrade a project which uses Butterknife v8.8.1 to make use of the new An...
butterknife All bind view are null
For mixed Java/Kotlin projects add the following lines to your module level build.gradle ...
butterknife android studio 3.2 canary with androidx not compiling (Today is google IO 2018)
error: package does not exist The imports inside the auto generated _View...
butterknife ButterKnife generates ViewBinding class with wrong resource ID
i am seeing this issue with 8.8.1 too especially after adding a new xml layout via copy and paste ...