mattleibow/square-bindings

Compiling issue with Picasso

streinhard opened this issue ยท 14 comments

When I include your Picasso binding and use it in my app, I get the following compilation errors:

error: package com.squareup.picasso does not exist
    com.squareup.picasso.Callback

com.squareup.picasso.Picasso does not exist
    com.squareup.picasso.Picasso.Listener

com.squareup.picasso does not exist
    public void onImageLoadFailed (com.squareup.picasso.Picasso p0, android.net.Uri p1, java.lang.Exception p2)

com.squareup.picasso does not exist
    private native void n_onImageLoadFailed (com.squareup.picasso.Picasso p0, android.net.Uri p1, java.lang.Exception p2);

Any idea how to solve this?

@monostefan That might be the linker removing members. If you turn off the linker, does the issue persist? If it goes away, then could you create a small sample project that produces this, or a similar, error? Does this same issue occur when you build the sample app?

Hmm, after switching to UrlImageViewHelper I tried the same Version of your Picasso Bindings again. Linking was and is disabled in Debug Config. However, now I get a completely different error:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Tool exited with code: 2. Output: Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/squareup/okhttp/Address;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/squareup/okhttp/Authenticator;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/squareup/okhttp/Cache$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/squareup/okhttp/Cache$2;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/squareup/okhttp/Cache$CacheRequestImpl$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/squareup/okhttp/Cache$CacheRequestImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/squareup/okhttp/Cache$CacheResponseBody$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/squareup/okhttp/Cache$CacheResponseBody;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/squareup/okhttp/Cache$Entry;

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:608)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)
Caused by: java.lang.InterruptedException: Too many errors
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:600)
    ... 4 more

Not really sure what is going on here and I have to investigate further.

Good news though: It works if I set up a new project and embed the bindings there.

Okay, the error above comes from modernhttpclient, which brings it's own version of OkHttp. Hence the namespaces collide. Any Idea how this collision could be avoided?

lukax commented

I`m having the same issue

Unfortunately at this time there is no workaround. However this has been fixed in ModernHttpClient for the next release. anaisbetts/ModernHttpClient#177
I would suggest not using ModernHttpClient temporarily, and then after the release, you can switch it back on. Performance may not be as great as it could be, but HttpClient can still work using the default implementation.

Hey @mattleibow , I can see your successful merge here, anaisbetts/ModernHttpClient#177 however I am unsure how to get both ModernHttpClient and Picasso working together. I have tried using both from nuget and using both from source but I can't seem to figure it out. Any tips/suggestions/examples?

EDIT: Hmmm... I made a sample project, added ModernHttpClient as new project, added Square.Picasso as new project. Updated the nuget packages in ModernHttpClient Square.OkHttp to 2.7.2.0" and Square.OkIO to 1.6.0.0. Seems to compile and run. Got it to load an image into an image view with Picasso and download data with ModernHttpClient. Not sure why it was not working in my other project.

Why is this closed? I have the same problem when using Picasso with ModernHttp.
Why don't you guys remove the .dll from the binding and replaced it with a nuget?

There exists a PR fix for this.
Why @jacksierkstra don't you release this?

@jzeferino I've already merged the pull request. What more do you expect from me? Be more specific please.

When this fix will be released? Thanks.

@jzeferino Again. Be more specific. What do you want me to do?

@jacksierkstra i need you to publish that fix in the next version of the picasso because now it has de okhttp.ddl attached to it.

@jacksierkstra do you understand it?

This library requires OkHttp and modernhttp client requires OkHttp as well, instead you can just use the Glide library which does not have a dependency with OkHttp and have the same API interface. Here is the , Glide library. Its also available on nuget.

Here is how am using it in my viewhlder :

Glide.With(context).Load(movie.Image.Url).Placeholder(Resource.Drawable.placeholder).Into(vh.ThumbNail);

@josephkandi thank you for that port.

Hello,

Any updater on this ? Does this library can use the okHttp nuget package instead of bringing it's own implementation ?

Regards.