Reputation: 2862
Hi I am trying to use the https://github.com/Swati4star/Images-to-PDF ImagesToPDF function from this library. I have added all the classes required in my application.
Now I have used picasso in my application before adding the ImagesToPDF function.
Now after adding it I am getting following error :
java.lang.NoSuchMethodError: No static method with(Landroid/content/Context;)Lcom/squareup/picasso/Picasso; in class Lcom/squareup/picasso/Picasso; or its super classes (declaration of 'com.squareup.picasso.Picasso' appears in /data/app/com.example.onboardingversion2-sJCkixxNOR2KPNLmYYdvpQ==/base.apk!classes2.dex)
Getting error in following function :
/**
* Opens Matisse activity to select Images
*/
private void selectImages() {
Matisse.from(this)
.choose(MimeType.ofImage(), false)
.countable(true)
.capture(true)
.captureStrategy(new CaptureStrategy(true, AUTHORITY_APP))
.maxSelectable(1000)
.imageEngine(new PicassoEngine())
.forResult(INTENT_REQUEST_GET_IMAGES);
}
app gets crashed and gives error. I added application and set Multidex
public class MyApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);
}
}
I also added multidexEnabled true in gradle. Still its throwing the error. Please help. Thank you.
Upvotes: 0
Views: 5301
Reputation: 356
GlideEngine() work for me using latest dependency
fun selectImages(frag: Fragment?, requestCode: Int) {
Matisse.from(frag)
.choose(MimeType.ofImage(), false)
.countable(true)
.capture(true)
.captureStrategy(CaptureStrategy(true, AUTHORITY_APP))
.maxSelectable(1000)
.imageEngine(GlideEngine())
.forResult(requestCode)
}
Upvotes: 0
Reputation: 1674
The problem is in the line
.imageEngine(new PicassoEngine())
where PicassoEngine() class uses Picasso.with(context).... module which is deprecated. The solution is you have to create a new class, name it NewPicassoEngine() as below;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
import com.zhihu.matisse.engine.ImageEngine;
public class NewPicassoEngine implements ImageEngine {
@Override
public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
Picasso.get().load(uri).placeholder(placeholder)
.resize(resize, resize)
.centerCrop()
.into(imageView);
}
@Override
public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView,
Uri uri) {
loadThumbnail(context, resize, placeholder, imageView, uri);
}
@Override
public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
Picasso.get().load(uri).resize(resizeX, resizeY).priority(Picasso.Priority.HIGH)
.centerInside().into(imageView);
}
@Override
public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
loadImage(context, resizeX, resizeY, imageView, uri);
}
@Override
public boolean supportAnimatedGif() {
return false;
}}
and use it as;
private void selectImages() {
Matisse.from(this)
.choose(MimeType.ofImage(), false)
.countable(true)
.capture(true)
.captureStrategy(new CaptureStrategy(true, AUTHORITY_APP))
.maxSelectable(1000)
.imageEngine(new NewPicassoEngine())
.forResult(INTENT_REQUEST_GET_IMAGES);
}
This will solve your problem.
Upvotes: 0
Reputation: 419
Picasso in not updated for about 4 years, it has many issues. Maybe You should switch to Glide
Upvotes: 1