JakeWharton / butterknife

Bind Android views and callbacks to fields and methods.
http://jakewharton.github.io/butterknife/
Apache License 2.0
25.56k stars 4.6k forks source link

Static member 'null.R2.id' accessed via instance reference #1703

Open MBalazs1234 opened 3 months ago

MBalazs1234 commented 3 months ago

I changed from R to R2 but the ID underlines it with the following text: Static member 'null.R2.id' accessed via instance reference

and when I try running the code it throws this error:

java.lang.annotation.AnnotationTypeMismatchException: Incorrectly typed data found for annotation element public abstract int butterknife.BindView.value() (Found data of type R2.id)
    at jdk.compiler/com.sun.tools.javac.model.AnnotationProxyMaker$ValueVisitor$1AnnotationTypeMismatchExceptionProxy.generateException(AnnotationProxyMaker.java:271)
    at java.base/sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:89)

Screenshot 2024-07-24 at 19 21 54

cwiapst commented 2 months ago

I had the same problem

diederikMrAwesome commented 3 weeks ago

The Android Gradle plugin upgraded with the following settings on in the gradle.properties file.

android.nonFinalResIds=false
android.nonTransitiveRClass=false

This seems to have worked for us. The longer term solution is still to move to ViewBinding however.