okhttp icon indicating copy to clipboard operation
okhttp copied to clipboard

3.6.0 Adress.class Duplication

Open rencsaridogan opened this issue 9 years ago • 3 comments

Hello,

I've come across similar issues which indicates the same problem. However, in my case it seems to be happening in a different way which shouldn't produce this issue as described below:

Imagine I have two internal private libraries, published on private maven repository named as below:

com.x.y.analytics com.x.y.player

Both of these libraries use OkHttp 3.6.0 with the given code snippet below:

provided 'com.squareup.okhttp3:okhttp:3.6.0'

So basically, I don't include the actual library when I'm releasing an aar to maven, I compile this and provide it to mentioned libraries from the parent project with the code snippet below:

compile 'com.squareup.okhttp3:okhttp:3.6.0'

However, even though everything should be fine due that there is only 1 compiled version of this library, I have the error given below:

Error:Execution failed for task ':application:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/Address.class

I believe this issue would happen if I used compile to inject the library inside the private libraries but since I use provided could you elaborate the issue if there are any leads to a fix?

rencsaridogan avatar Feb 15 '17 08:02 rencsaridogan

I suspect people with build tools / Gradle experience might be more helpful. Maybe ask on StackOverflow?

swankjesse avatar Feb 15 '17 14:02 swankjesse

Thanks @swankjesse.

I'll ask on StackOverflow as well and provide an answer here if there is any to solve this issue. However, if there are any findings this should be also open since this issue doesn't occur with any other library than OkHttp which makes OkHttp unique with this issue.

rencsaridogan avatar Feb 15 '17 14:02 rencsaridogan

If those two libraries actually depend on OkHttp being present then you should have their dependencies marked as compile, not provided. All build systems handle this transitive duplicate case and would pull the library in only a single time.

Otherwise you can use ./gradlew :app:dependencies to see the dependency tree and where OkHttp is being included twice.

JakeWharton avatar Feb 15 '17 16:02 JakeWharton