1

Unable to find Butterknife.Action and ButterKnife.apply on upgrading the Butterknife version 8.8.1 to version 10.2.0

error: cannot find symbol
public static final ButterKnife.Action<View> GONE = (view, index) -> view.setVisibility(View.GONE);
                               ^
  symbol:   class Action
  location: class ButterKnife
Shubham Jain
  • 2,365
  • 2
  • 17
  • 29

2 Answers2

1
  • Batterknife.aply depricated in AndroidX

If you migrate to AndroidX you must use:

in gradle

dependencies {

implementation "com.jakewharton:butterknife:10.2.0"

annotationProcessor "com.jakewharton:butterknife-compiler:10.2.0" 

...}

in class when you have errors

if you use code like this:

- ButterKnife.apply(new View[]{ ivImageId,vgSubscribtionsId,vgSubscribersID},

                    (view, value, index) -> view.setVisibility(value), View.INVISIBLE);

replace to this for work with AndroidX:

- butterknife.Action viewAction = (view, index) -> {

                view.setVisibility(View.INVISIBLE);

            };
            butterknife.ViewCollections.run(new View[]{ ivImageId,vgSubscribtionsId,vgSubscribersID} , viewAction );
Plutian
  • 2,276
  • 3
  • 14
  • 23
Yaroslav.P
  • 19
  • 3
0

Those methods are deprecated and no longer available since version 10.0.0: more details here and here.

Jesús Hagiwara
  • 363
  • 2
  • 8
  • 14