Skip to content

Unable to Use @AndroidEntryPoint with androidx.car.app Android Auto Screen #4758

Open
@vishwadg

Description

@vishwadg

Configuration:

Hilt version: 2.51.1
Car App Library version: androidx.car.app:app:1.4.0

Issue Summary:
I'm encountering an issue when trying to use Hilt's @AndroidEntryPoint annotation within a class that extends androidx.car.app.Screen in an Android Auto app.

Context:
In my Android Auto application, I attempted to annotate a Screen class with @AndroidEntryPoint to enable dependency injection. However, this results in the following error:

[Hilt] @AndroidEntryPoint base class must extend ComponentActivity, (support) Fragment, View, Service, or BroadcastReceiver.

Since Screen is not a subclass of any of the supported Android components (e.g., Activity, Fragment, View, etc.), Hilt does not currently support injection in this context.

Feature Request / Question:
Is there a recommended way to use Hilt for dependency injection within Screen classes in Android Auto apps? If not, would it be possible to extend Hilt support to include Screen or provide guidance on best practices for DI in this scenario?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions