question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

XX_MembersInjector.class is repeatedly generated in the wrong package

See original GitHub issue

demo’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:closed
  • Created 6 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

27reactions
HassanIbraheemcommented, Nov 29, 2017

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 a MembersInjector for it in base module. When dagger processes the other modules, and doesn’t find that MembersInjector, 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 to Middle class. This will make dagger generate the MembersInjector in the base module, and it won’t be generated in other modules any more.

4reactions
KingJ0629commented, Nov 30, 2017

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found