Giter Club home page Giter Club logo

Comments (6)

alveru avatar alveru commented on June 9, 2024 1

hi @kuanyingchou ,

thanks for your quick response, i tried it in the dummy project and then in the real project, i moved versions and now is working,

implementation 'com.google.dagger:dagger-android:2.51'
//implementation 'com.google.dagger:dagger-android-support:2.17'
//annotationProcessor 'com.google.dagger:dagger-android-processor:2.17'
annotationProcessor 'com.google.dagger:dagger-compiler:2.48'
//kapt 'com.google.dagger:dagger-android-processor:2.17'
kapt 'com.google.dagger:dagger-compiler:2.48'

i am closing the ticket, thanks for your prompt support!

from dagger.

kuanyingchou avatar kuanyingchou commented on June 9, 2024

Hi, @alveru , the missing binding error says that Dagger doesn't know how to provide DetailsViewModel. This is because now that DetailsViewModel is assisted injected, it is not included in the graph anymore. You can try removing your bindDetailsViewModel() or ViewModelModule.

from dagger.

alveru avatar alveru commented on June 9, 2024

Hello ,

thanks for your prompt response, what you mentioned solved that problem, though now the Factory is the one sending the error, since it cannot be injected :(

error: [Dagger/MissingBinding] DetailsViewModel.Factory cannot be provided without an @Provides-annotated method.
void inject(DetailsActivity activity);

i tried putting @AssistedInject too in the variable but didn't work:

class DetailsActivity : AppCompatActivity() {
@AssistedInject
lateinit var viewModelFactory: DetailsViewModel.Factory

  • I also tried adding @singleton to the factory but that failed too

    companion object {
    @Suppress("UNCHECKED_CAST")
    @singleton
    fun factory(
    factory: Factory,
    id: String
    ) : ViewModelProvider.Factory {
    return object : ViewModelProvider.Factory {
    override fun create(modelClass: Class): T =
    factory.create(id) as T
    }
    }
    }

Do you know where should i place the provider so Dagger can inject it?

Thanks in advance

from dagger.

kuanyingchou avatar kuanyingchou commented on June 9, 2024

Hi, @alveru , you shouldn't need a provider for DetailsViewModel.Factory. Could you share a minimal project to reproduce this?

from dagger.

alveru avatar alveru commented on June 9, 2024

Hi @kuanyingchou

thanks for your reponse, yes, i am attaching a dummy project with the similar configuration to that of my project, with java & kotlin files, it shows the same @provides error when trying to inject the viewmodel assisted factory, the project is in a zip file:

AssistedTest.zip

from dagger.

kuanyingchou avatar kuanyingchou commented on June 9, 2024

Hi, @alveru , I think it's because you're mixing Dagger 2.35.1 and 2.17 in you build.gradle.kts:

    implementation("com.google.dagger:dagger-android:2.35.1")
    //implementation("com.google.dagger:dagger-android-support:2.17")
    annotationProcessor("com.google.dagger:dagger-android-processor:2.17")
    annotationProcessor("com.google.dagger:dagger-compiler:2.17")
    //debugImplementation("androidx.compose.ui:ui-test-manifest:1.8.2")
    kapt("com.google.dagger:dagger-android-processor:2.17")
    kapt("com.google.dagger:dagger-compiler:2.17")

You'll have to allign all Dagger artifacts to the same version and it has to be higher than 2.31, where assisted injection was introduced.

from dagger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.