[Hilt] Dynamic Feature R8 isMinifyEnabled = true, showing error: is defined multiple times
See original GitHub issueVersion
Hilt: 2.28.3-alpha in :base
module
Using vanilla dagger in :dynamic-feature
module
AGP: 4.0.1
GWP: 6.5.1
Kotlin: 1.3.72
Problems
Context
R8 isMinifyEnabled = false, succeed to build & runs, otherwise it fails as described in the title
Question
- Is it currently not supported to define same dependency class in multiple class and used injected across dynamic feature module?
- Is it R8 restriction due to multiple class defined? and how to solve that?
Our usecase:
:data
is a java only module
class MapperA @Inject constructor()
class AuthRepositoryImpl @Inject constructor(
private val mapper: MapperA
) : AuthRepository
class AccountRepositoryImpl @Inject constructor(
private val mapper: MapperA
) : AccountRepository
:dynamic-feature:auth
module
@DisableInstallInCheck
@Module
interface AuthModule {
@get:[Binds]
val AuthRepoistoryImpl.repository: AuthRepository
}
:dynamic-feature:account
module
@DisableInstallInCheck
@Module
interface AccountModule {
@get:[Binds]
val AccountRepoistoryImpl.repository: AccountRepository
}
I’ve tried to implement @Qualifers
to annotate it as different dependencies but doesn’t work either, see here #2074
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Dynamic feature modules couldn't generate correctly with AGP ...
So it fails minifyReleaseWithR8 task in our app in release build. Pls check below stack trace: DataBindingCallbacks.class is a class we defined ......
Read more >minifyWithR8 issue with Dynamic feature module, release build
I am working on a dynamic feature module for the first time. ... ListenableFuture is defined multiple times: ... com.android.tools.r8.
Read more >R8 Minify: Type Defined Multiple Times - ADocLib
I'm getting this error when I try to add an implementation to my app's gradle file for Contentful Type com.google.gson.ExclusionStrategy is defined multiple....
Read more >Dependency injection with Hilt | Android Developers
To learn more about which lifecycle callback an Android class gets injected in, see Component lifetimes. Define Hilt bindings. To perform field injection,...
Read more >The Ultimate Dagger-Hilt Guide (Dependency Injection)
Dependency injection is a core concept of software development. In this video, I'll show you how you can apply DI in an Android...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Since it is
MapperA_Factory
that is being duplicated, my guess as to what is going on here is that you aren’t running the Dagger processor over theMapperA
class and are pulling it into two different Dagger components.Factory generation for
@Inject
classes can happen in two places: on the class itself if you run the Dagger processor (preferred) or lazily when used by the Dagger component. The problem with the second case is that if you have two Dagger components built separately we’ll generate the same factory twice. (There’s also a separate problem that generating it at the component can reduce build parallelism if you have a lot of factory classes to generate too, but that isn’t your direct issue right now).Nice! Closing this issue now~