0

I was using butter knife from past 1 year in my project, it was all working fine. Now I update android studio with 3.0 and butter knife with 8.8.1. I have changed binding method with @BindViewas per instruction. Have added compiler too.

compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

Also updated build tool version to

buildToolsVersion "27.0.2"

Also added flavour dimension.

Also, remove gradle apt plugin:

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'

Offline work of Gradle is already unchecked.

  try {
        ButterKnife.bind(this);
    } catch (Exception e) {
        e.printStackTrace();
        if (BuildConfig.DEBUG) {
            showToast(e.getMessage());
        } else {
            showApologies();
            finish();
        }
        Log.e("butterknife", e.getMessage());
    }

And the message print is :

  W/System.err: at butterknife.internal.Utils.findRequiredView(Utils.java:92)
  W/System.err: at butterknife.ButterKnife.createBinding(ButterKnife.java:199)
  W/System.err: at butterknife.ButterKnife.bind(ButterKnife.java:124)

Please give me a solution or put your views on it.

Minkoo
  • 439
  • 1
  • 3
  • 16
  • which error u can get in `Logcat` plzz show hear – Ali Mar 01 '18 at 09:06
  • what error you get? – Hemant Parmar Mar 01 '18 at 09:08
  • You might need to migrate `compile` keyword to `implementation` in order for it to build. https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html and https://stackoverflow.com/questions/44402024/why-android-change-compile-to-implementation-configuration-in-gradle-depende – Shobhit Puri Mar 01 '18 at 09:11
  • java.lang.IllegalStateException: Required view 'gpca_header_iv' with ID 2131296851 for method 'headerBack' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) annotation. – Minkoo Mar 01 '18 at 09:17
  • @ShobhitPuri I have changed all dependencies, do i need to changes these too, compile fileTree(include: ['*.jar'], dir: 'libs') compile project(':library') compile project(':gpvolley') ? – Minkoo Mar 01 '18 at 09:30
  • @ShobhitPuri - No change, not able to bind views. – Minkoo Mar 01 '18 at 09:34
  • Yes, the local libraries need changes too. What error its throwing? – Shobhit Puri Mar 01 '18 at 10:06
  • Resolved, Issue was with the binding. In the previous versions of Butter Knife, for multiple views, we use Nullable before OnClick and Bind. But in the new version, we have to use Optional before Onclick and Nullable before BindView. – Minkoo Mar 01 '18 at 10:28

0 Answers0