I’m triying to add Okhttp library to my Android project, which uses Estimote Android SDK. It seems that the Estimote Android SDK has included that library (an older version), but the problem is that other dependencies I have included to my app (like Picasso) can’t access to that dependencies, just my own classes can. Picasso, to initialize the image caching system, needs to instantiate OkhttpClient object by his own and this class can be found in the Okhttp library. But, it seems that a dependency can’t access to another dependencies’ library. I don’t know how to explain it…
If I add the Okhttp dependency to my Gradle, after 7 minutes of building, the build fails with a “dexDebug” error. That means that the same library is included twice (one in the Estimote SDK and other in my Gradle).
Yes, we do include OkHttp but library is repackaged (into package com.estimote.sdk.repackaged.okhttp_v2_2_0.com.squareup.okhttp) so there should be no collision at all.
You would have two OkHttpClient classes:
com.estimote.sdk.repackaged.okhttp_v2_2_0.com.squareup.okhttp.OkHttpClient
and com.squareup.okttp.OkHttpClient
and that’s perfectly fine. With Picasso you need to use the second one.
Thanks for your reply. Now I’m trying to use the library included from Maven Central but I get the same error.
Picasso.Builder builder = new Picasso.Builder(this);
OkHttpDownloader downloader = new OkHttpDownloader(this, Integer.MAX_VALUE);
// OkHttpDownloader is a Picasso's class, and then this needs OkHttpClient object from OkHttp library. But it seems that a library can't access to Estimote's library.
builder.downloader(downloader);
Picasso built = builder.build();
built.setIndicatorsEnabled(true);
built.setLoggingEnabled(true);
Picasso.setSingletonInstance(built);
OkHttpDownloader is a Picasso’s class, and to instantiate this class I need to include OkHttp dependency. But, if I do that, the project won’t compile because Estimote’s library also has an OkHttp dependecy in it and colides with my OkHttp dependency. The thing is that OkHttpDownloader class (that’s inside Picasso’s library) needs to instantiate a OkHttpClient object, that is found in OkHttp library, and Picasso can’t reach the OkHttp library which is in Estimote dependency.
Maybe that wasn’t crystal clear. Do not use OkHttpClient from Estimote SDK as it is our repackaged, private dependency which is subject to change without any notice.