Questions tagged [butterknife]

An annotation-based Android view "injection" framework aimed at reducing boilerplate.

View "injection" library for Android which uses annotation processing to generate boilerplate code for you.

  • Eliminate findViewById calls by using @Bind on fields.
  • Group multiple views in a list using @BindViews. Operate on all of them at once with actions, setters, or properties.
  • Eliminate anonymous inner-classes for listeners by annotating methods with @OnClick and others.

The documentation includes additional code examples and use cases.

ButterKnife is open sourced under Apache 2.0 license.

536 questions
126
votes
10 answers

The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. for androidx

I upgraded my android studio to 3.4 canary and now I cannot successfully build anymore due to the following error: The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten.…
Tnaffh
  • 1,313
  • 2
  • 8
  • 12
69
votes
5 answers

Difference between Dagger and ButterKnife Android

Can anyone point out the difference between Dagger and Butterknife? I know that Butterknife is a view injection library and Dagger is a dependency injection library. But the documentation online seems a bit overhead for me. According to Butterknife…
user2511882
  • 9,022
  • 10
  • 51
  • 59
63
votes
8 answers

Dagger and Butter Knife vs. Android Annotations

I am evaluating Dependency Injection (DI) frameworks for an Android app. The top contenders are: Dagger (with Butter Knife) and Android Annotations. I understand that Dagger and ButterKnife are from the same source- square and they complement each…
59
votes
11 answers

ButterKnife 8.0.1 not working

I am using butterknife 8.0.1, but a nullpointerexception is appearing. This line is on my build.grade file: compile 'com.jakewharton:butterknife:8.0.1' this is my Main Class: (I wrote the includes properly) import…
Sebastian Corradi
  • 1,353
  • 2
  • 14
  • 25
58
votes
10 answers

Android: Kotlin with Butterknife

I'm trying to use Kotlin with Butterknife for my Android Application. Here is my build.gradle dependencies { ... compile 'com.jakewharton:butterknife:8.0.1' kapt 'com.jakewharton:butterknife-compiler:8.0.1' } kapt { generateStubs =…
Rahul
  • 1,727
  • 3
  • 18
  • 33
56
votes
11 answers

java.lang.VerifyError: Verifier rejected class on Lollipop when using release APK

I get this error when I install my release APK on a 5.x device. The error does not occur when I push the same code from Android Studio, or if I run it on a 4.x device. java.lang.VerifyError: Verifier rejected class…
Austyn Mahoney
  • 11,398
  • 8
  • 64
  • 85
52
votes
5 answers

Remove "Method is never used" warning for OnClick annotation in Android Studio

Sorry if this question has been asked before. I am using the Butterknife 5.0 with the latest version of Android Studio(0.5.7). How can I remove the "Method is never used" warning for methods that use the 'OnClick' Annotation of ButterKnife.I noticed…
TMS
  • 1,201
  • 1
  • 13
  • 20
51
votes
3 answers

Android Butterknife - binding in fragment

I'm using Butterknife for the first time but something must be wrong. I have a fragment and a Listview and a TextView just for testing but Butterknife wont bind my variables: public class MyFragment extends Fragment { @Bind(R.id.resultListView)…
breakline
  • 5,776
  • 8
  • 45
  • 84
46
votes
5 answers

Gradle DSL method not found: 'apt()'

I am trying to add the latest version of butterknife and I get this error from gradle: Error:(31, 0) Gradle DSL method not found: 'apt()' Possible causes:The project 'MyProject' may be using a version of Gradle that does not contain the method.…
Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173
34
votes
2 answers

Impact to ButterKnife from "Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them as annotation attributes"

I'm using annotated attributes all over my Android project to bind Views and events to fields and methods. @BindView(R.id.textViewOrderId) TextView textViewOrderId; @OnClick(R.id.buttonDateFilter) public void onButtonDateFilter(View view)…
33
votes
9 answers

lateinit property has not been initialized

I have a custom linearlayout class and when I want to create instance of this class, I get the following error: lateinit property has not been initialized I'm using the latest version of butterknife library. The following is my Kotlin class: class…
Jemo Mgebrishvili
  • 5,187
  • 7
  • 38
  • 63
33
votes
6 answers

Where should I unbind ButterKnife 8.x.x in a ViewHolder?

I have a RecycleView.ViewHolder class which use ButterKnife annotations. Should my code unbind() in this ViewHolder class too? public class AView extends RecyclerView.ViewHolder { @BindView(R.id.a_text_view) TextView aText; public…
32
votes
6 answers

Kotlin Android View Binding: findViewById vs Butterknife vs Kotlin Android Extension

I'm trying to figure out the best way to do Android View Binding in Kotlin. It seems like there are a few of options out there: findViewById val button: Button by lazy { findViewById
triad
  • 20,407
  • 13
  • 45
  • 50
31
votes
8 answers

How can I fix this error with ButterKnife in Android Studio?

Building succeeds, but running on an emulator fails with this message in the console: Cause: superclass access check failed: class butterknife.compiler.ButterKnifeProcessor$RScanner (in unnamed module @0x65e8e2f6) cannot access class…
justColbs
  • 1,504
  • 2
  • 18
  • 28
31
votes
4 answers

Duplicate files while including butterknife with gradle

I have a basic Android app that I created with Android Studio, and I'm having problems adding butterknife to my build. I get this error: Error:: duplicate files during packaging of APK…
Andres Olarte
  • 4,380
  • 3
  • 24
  • 45
1
2 3
35 36