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.

Hello. Thank you so much for developing/maintaining Dagger2. I have a problem with @BindsOptionalOf. Here is a primitive example of code https://gist.github.com/dmitro-ivanov/e03493211ebf0151cfebc5a6062b0a83. As I could see from the documentation it is legal to inject Optional<IRepository>, but at compile-time, I have the issue error: incompatible types: Optional<Object> cannot be converted to Optional<IRepository> Because the generated method injectMainActivity is using Optional.empty() without explicit specifying type. A workaround that helps is that inject-field should be Provider<Optional<IRepository>>.

Am I doing something illegal? or it is a bug?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
danysantiagocommented, May 5, 2020

Not the Dagger version, the ‘java source version’ also known as ‘target version’.

In an Android project this is usually found in the android closure, like this:

android {
    // ...
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

It can also be manually configured using the Kotlin plugin:

kotlinOptions {
    jvmTarget = "1.8"
  }

Also, what version of Kotlin are you using?

0reactions
dmytroivanovvcommented, May 6, 2020

I did not specify jvmTarget. When I added

kotlinOptions {
        jvmTarget = "1.8"
    }

Everything works fine. There is no more problem. Thank you. Maybe it will be useful for someone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BindsOptionalOf - Dagger
Annotates methods that declare bindings for Optional containers of values from bindings that may or may not be present in the component.
Read more >
Optional Binding in Swift. Avoid those force unwraps - Medium
Optional Binding. Optionals are a basic feature of Swift, and allow values to take either a value of .some or .none.
Read more >
Optional Binding In Swift - Dev Genius
So we have been talking about optional binding, so let us cover how this works and why it is essential. Optional binding is...
Read more >
OptionalBinder (Guice 4.1 API) - Google
An API to bind optional values, optionally with a default value. OptionalBinder fulfills two roles: It allows a framework to define an injection...
Read more >
How to add optional @Bindings to SwiftUI views - FIVE STARS
Making the binding state optional. With FSDisclosureGroup there's no way around it: it needs a Binding<Bool> state.
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