Coder Social home page Coder Social logo

auto-dagger's Issues

Feature Suggestion: Add support for auto binding for third party libraries

I think that it would be amazing if this library (perhaps via non-core additional modules) could support autobinding various, well known libraries commonly used.

I had two in mind specifically here:

  • Retrofit: i currently have to always remember to create a binding for the retrofit routes i create and I always forget. Having an annotation that can be added to the retrofit interface itself would save a lot of duplication

  • Sqldelight: I ALWAYS forget to add new XXXQueries classes that are created when i create a new table, to the dependency graph. Having a tool autobind all the existing Queries classes would save so much effort

Applying the android library makes it difficult to write Compose UI tests

Describe the bug

Adding the se.ansman.dagger.auto:android seems to effectively force you to run your Application to implement GeneratedComponentManagerHolder. However, when writing pure Compose tests, this is likely not the case.

To Reproduce

Create an Android library module (e.g. :testing) and add the se.ansman.dagger.auto:android library as an implementation dependency. Then, create a simple Compose Test using createComposeRule():

class TextTest {
    @get:Rule
    val composeRule = createComposeRule()

    @Test
    fun textIsVisible() {
        composeRule.setContent {
            Text("Text label")
        }

        composeRule.onNodeWithText("Text label").assertExists()
    }
}

Expected behavior

Running ./gradlew :testing:connectedAndroidTest should run without any problems.

Actual behavior

The following exception is thrown (newlines added for readability):

java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider:
androidx.startup.StartupException: java.lang.IllegalStateException:
Expected application to implement GeneratedComponentManagerHolder.
Check that you're passing in an application context that uses Hilt.
Application class found: class android.app.Application

Environment

  • Kotlin Version: 1.9.23
  • KSP or KAPT: KSP
  • KSP version: 1.9.23-1.0.20
  • Dagger Version: 2.51.1
  • Hilt Version: 1.1.0

Additional context

Applying the se.ansman.dagger.auto:android-testing doesn't help. I didn't expect it to, either, but I figured it was worth trying.

Plugins applied:

  • com.android.library
  • com.google.dagger.hilt.android
  • com.google.devtools.ksp
  • org.jetbrains.kotlin.android

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.