Mindaugas Nakrosis
Mindaugas Nakrosis

Reputation: 138

Gradle duplicate classes in dependencies

I am building an android application and am using recaptcha and easywsdl repositories. These both repositories contain okhttp and okio jars and I get error while starting app that duplicate classes exist. However, these are not the same. If I exclude okhttp from the project (added by recaptcha repository) recaptcha doesn't have particular methods that are described in okhttp.jar added by recaptcha.

Code snippet: http://pastebin.com/fDuYUH76

Don't know how to paste it here. Formatting crashes.

Upvotes: 4

Views: 2693

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35785

Gradle does not solve conflicts that arise from two different jars having shared classes. If you have two jars with same artifactId and different version, it will only take one of them. If you have two different artifactId's, gradle cannot do anything about it.

If the simultaneous use of the two jars makes your application crash, you can only use one of them. If your application doesn't run with only one of the jars, it probably cannot be built in the way you intend it.

By the way: This is not a problem of having multiple repositories, but a problem of having clashing jars on the classpath.

Upvotes: 5

Related Questions