XX_MembersInjector.class is repeatedly generated in the wrong package
See original GitHub issuedemo’s url : https://github.com/kj387948407/DaggerBugTest
dagger2 generates Middle_MembersInjector.class should be in this package com.uama.happinesscommunity.base at the module base, but in the demo, The file is repeatedly generated in module mine and module user, respectively, and build the project, throws exception: `Error:Execution failed for task ‘:app:transformClassesWithDexForDebug’.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/uama/happinesscommunity/base/Middle_MembersInjector;`
and mine another project throws exception `Error:Execution failed for task ‘:app:transformClassesWithJarMergingForXflcDevelop’.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/uama/happinesscommunity/base/Middle_MembersInjector.class`
Middle_MembersInjector.class exactly the same, and in the same directory, resulting in an error. Do not know whether this understanding is correct.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
Just faced this issue as well. Found #814 which seems to be the same.
The generated MembersInjector is in the right package, but is generated in multiple modules.
If I understood it correctly, this happens when your
Middle
class doesn’t need any injections, so dagger doesn’t generate aMembersInjector
for it inbase
module. When dagger processes the other modules, and doesn’t find thatMembersInjector
, it generates one, in each module.The duplicate generated
MembersInjector
are actually not used at all, and you’ll only get the error when you assemble the top-level module (app
).A workaround that seems to work, is adding an unneeded
@Inject
field toMiddle
class. This will make dagger generate theMembersInjector
in thebase
module, and it won’t be generated in other modules any more.@hsnim You understand quite right, I met this problem a half month ago, it is the same way as you temporarily solve for a moment.