【问题标题】:java.lang.NoSuchMethodError when using Picasso使用毕加索时的 java.lang.NoSuchMethodError
【发布时间】:2016-07-08 21:27:06
【问题描述】:

我正在使用Picasso 处理带有多个图像的ViewPager。但它给了我这个错误

java.lang.NoSuchMethodError: 没有虚拟方法加载(Ljava/lang/String;)Lcom/squareup/picasso/RequestBuilder;在 Lcom/squareup/picasso/Picasso 类中;或其超类(“com.squareup.picasso.Picasso”的声明出现在 /data/app/com.example.myapp-1/base.apk 中)

当像这样使用时

Picasso.with(mContext)
        .load(url)
        .centerCrop()
        .resize(imageView.getMeasuredWidth(),imageView.getMeasuredHeight())
        .error(R.drawable.detail_placeholder)
        .placeholder(R.drawable.detail_placeholder)
        .into(imageView);

任何帮助将不胜感激。

【问题讨论】:

  • Clean and built 并使用最新的compile 'com.squareup.picasso:picasso:2.5.2'
  • @MD 我正在使用 Eclipse。
  • 加入Android Studio
  • 这不是一个真正的答案
  • mContext 使用什么上下文?

标签: java android picasso


【解决方案1】:

试试这段代码,我现在在我的应用程序中使用它

// "this" is the context here
Picasso.with(this)
       .load(personPhotoUrl)
       .placeholder(R.drawable.avatar)
       .error(R.drawable.avatar)
       .into(mImageViewProfilePic);

我的毕加索 jar 文件版本 2.4.0

如果不是这样,您可以尝试使用图像加载器库或 Gilde 加载图像。

【讨论】:

    【解决方案2】:

    尝试将 OkHttp 依赖项添加到您的 build.gradle(应用级)中:

    编译'com.squareup.okhttp:okhttp:+'

    编译'com.squareup.okhttp:okhttp-urlconnection:+'

    编辑:哦,抱歉,您使用的是 Eclipse,因此您可能需要获取 jar 文件:

    https://search.maven.org/remote_content?g=com.squareup.okhttp3&a=okhttp&v=LATEST

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-29
      • 1970-01-01
      • 1970-01-01
      • 2016-02-09
      • 2016-04-02
      • 2016-06-18
      相关资源
      最近更新 更多