java.lang.NoClassDefFoundError: com.squareup.picas

2019-07-18 16:26发布

问题:

I try to use Picasso for the first time

like in the official site example:

private void setItemBgImageUsingPicasso(View convertView) {
    String imageUrl = getImageUrlFromOffer(convertView);

    ImageView offerImage = ((ImageView) convertView
            .findViewById(R.id.offerImage));
    Picasso.with(mOffersListActivity).load(imageUrl).into(offerImage);
}

but I get this error:

08-09 17:37:43.309: E/AndroidRuntime(17821): java.lang.NoClassDefFoundError: com.squareup.picasso.Picasso
08-09 17:37:43.309: E/AndroidRuntime(17821):    at com.zoomer.general.ImageAdapter.setItemBgImageUsingPicasso(ImageAdapter.java:384)

回答1:

You should put it in libs folder and Eclipse will pack it properly for you.

Or you leave it as it is, but go to project properties, Export tab and check the library. This way Eclipse will pack it in the final APK.



回答2:

if using Android Studio, I found the problem to be related to proguard so, the following fixed the issue:

1) Add this to your proguard-rules file: -keep class com.squareup.picasso.** { *; }

2) Clean the project

3) Re-build