Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate class found in modules modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1) #5235

Closed
efinder2 opened this issue Aug 22, 2019 · 8 comments

Comments

@efinder2
Copy link

efinder2 commented Aug 22, 2019

Description

I tried to add start testing my app with robolectric. But on the first build I got a duplicated class error (see log.txt)

dependency_tree.txt

Steps to Reproduce

Create a new Project in Android studio, add robolectric 4.3 to the dependencies (or use the Code from the repo) and try to Start ExampleInstrumentation Test.

build.gradle.txt

Robolectric & Android Version

Tried to test on an Android 8.1 and use Robolectric 4.3

Link to a public git repo demonstrating the problem:

https://github.com/efinder2/RobolectricSample

P.S.
see this StackOverflow post

@Prafulla-Nair
Copy link

I've the same issue

@fejd
Copy link

fejd commented Aug 28, 2019

I suddenly ran into this issue in an existing app with working tests. No changes in the build files or tests, the tests started failing suddenly.
My only guess is that the artifact in the Gradle cache was synced and updated. I'm using Robolectric 4.2 though.

@kacso
Copy link

kacso commented Sep 2, 2019

I'm experiencing same issue when running gradle assembleAndroidTest task (executed by jitpack CI), but when gradle build or gradle install (to install library locally) is performed, everything works fine.

Any info on how to resolve this?

@efinder2
Copy link
Author

efinder2 commented Sep 6, 2019

Finally solved it by removing the duplicated libraries manually: https://stackoverflow.com/a/57819278/4140943
Could this be added in the library? The library with the problem (org.apache.maven:maven-ant-tasks:2.1.3) is no longer maintained.

@efinder2 efinder2 closed this as completed Sep 6, 2019
@efinder2 efinder2 reopened this Sep 6, 2019
@Pozzoooo
Copy link

Pozzoooo commented Sep 9, 2019

+1, facing the issue using Robolectric 4.0.2

@ibcoleman
Copy link

Same issue on 4.3.1

@mochadwi
Copy link

mochadwi commented Jan 19, 2020

you are a lifesaver @efinder2 excluding the dependency works for me for 4.3.1. But I'm curious why you reopened this issue?

  1. Attempt zero (Conflicted transitive dependency)
// Conflicted transitive dependency for androidx.test:monitor
- org.robolectric:robolectric -> androidx.test:monitor:1.2.0 (forced to use 1.1.0)
- androidx.test:core -> androidx.test:monitor:1.1.0
- androidx.test:runner -> androidx.test:monitor:1.1.0

// Conflicted transitive dependency for com.google.guava:listenablefuture
- androidx.test.ext:truth -> androidx.test:monitor:9999.0 (forced to use 1.0)
- androidx.work:work-runtime -> androidx.test:monitor:1.0

I just forced it to exclude the conflicted version, See here for detail. My problems:

  1. Attempt one (Ignore/excluding the maven-task related)
    Seems to work, but show NoClassDefError

  2. Attempt two (Using sharedTest and roboelectric:annotations)
    does from qiita.com website solve your issue @ibcoleman @Pozzoooo @efinder2

https://qiita.com/sekitaka_1214/items/5569925db2d5f27ba712 (originally from japanesse)

Screen Shot 2020-01-19 at 4 05 31 PM

thanks @sekitaka for providing the answer

// wrong 
androidTestImplementation  "org.robolectric: robolectric: $ robolectricVersion"

// Positive 
androidTestImplementation  "org.robolectric: annotations: $ robolectricVersion"
  1. Attempt three (Check for conflicting/unnecessary dependencies)
    See here for details. This has happened when we configured for both testImplementation & androidTestImplementation, we don't need the unitTest one, so removed the roboelectric and keep for instrumentation test instead.

  2. Attempt four (Duplicate class for org.codehaus.classworld)
    When seeing the ./gradlew dependencies, roboelectric depends on the classworld libs, but I don't know which library that conflicted with roboelectric transitive dependency version. Same problem hapened here

@hoisie
Copy link
Contributor

hoisie commented Sep 4, 2020

maven-ant-tasks is no longer a dependency for Robolectric 4.4

@hoisie hoisie closed this as completed Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants