question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing resource ID for OnClick annotation

See original GitHub issue

#974 perhaps related to that, it is able to generate correct _ViewBinding code for views but somehow not for OnClick functions.

View view;
    target.toolbar = Utils.findRequiredViewAsType(source, R.id.toolbar, "field 'toolbar'", Toolbar.class);
    view = Utils.findRequiredView(source, com.mypackage.R.id.information_about, "field 'info' and method 'onClickAbout'");
    target.info = view;
    view7f0b006e = view;
    view.setOnClickListener(new DebouncingOnClickListener() {
      @Override
      public void doClick(View p0) {
        target.onClickAbout();
      }
    });
    view = Utils.findRequiredView(source, 2131427440, "method 'onClickTermsAndCondition'");
    view7f0b0070 = view;
    view.setOnClickListener(new DebouncingOnClickListener() {
      @Override
      public void doClick(View p0) {
        target.onClickTermsAndCondition();
      }
    });

It looks like it’s still use an int reference rather than actual R reference for OnClick I’m using latest BK and kotlin 1.3.30

Thanks.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
JakeWhartoncommented, Apr 16, 2019

When I find time I will

On Tue, Apr 16, 2019, 7:26 PM WenChao Kong notifications@github.com wrote:

@JakeWharton https://github.com/JakeWharton I have uploaded the sample, can you please have a look see if it can be reproduced?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JakeWharton/butterknife/issues/1498#issuecomment-483879937, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEERylgi6f9KUVvKg7AZBrpqPgPMM1ks5vhlw0gaJpZM4cu9WE .

5reactions
cooperkongcommented, Apr 15, 2019

Hi, here is the repo to reproduce this issue https://github.com/cooperkong/butterknifeR2issue It crashes with ResourceNotFound if launch Activity2 which is in a seperate module. however if I uncomment @BindView in Activity2 it works.

class Activity2: AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.lib2_layout)
        ButterKnife.bind(this)
    }
//    @BindView(R2.id.textview2)
//    lateinit var textView: TextView

    @OnClick(R2.id.textview2)
    fun donothing() {

    }
}

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resource IDs will be non-final by default in Android Gradle ...
I have an warning in Android Studio about my navigation drawer resources. Warning is Resource IDs will be non- ...
Read more >
View.OnClickListener - Android Developers
onClick. Android Developers · Docs · Reference. Was this helpful? On this page; Summary. Public methods. Public methods. onClick. Added in API level...
Read more >
SwiftUI iOS 14 MapKit Annotation Tap Gesture (didSelect)
I have a very simple map with annotation markers. ... iOS 14 SwiftUI Map() is missing a lot of the functionality of MKMapView....
Read more >
Lint Issue Index - Google Samples
... AnnotationProcessorOnCompilePath: Annotation Processor on Compile Classpath ... NonConstantResourceId: Checks use of resource IDs in places requiring ...
Read more >
Kotlin and Android From Scratch Flashcards | Quizlet
- Use a naming convention to pass the ID in the form R.<type>. - None of the above. - Use resource annotations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found