我的代码:
Picasso picasso = Picasso.with(getActivity());
picasso.load("http://static1.gamespot.com/uploads/original/1550/15507091/2867734-7512874458-CAK00.jpg")
.error(R.drawable.error)
.placeholder(R.drawable.placeholder)
.into(imageView);
还在清单
中添加了必需的权限<uses-permission android:name="ANDROID.PERMISSION.INTERNET" />
<uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE" />
修改
Logcat输出
Could not find method java.nio.file.Files.newOutputStream, referenced from method okio.Okio.sink
VFY: unable to resolve static method 19774: Ljava/nio/file/Files;.newOutputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/OutputStream;
VFY: replacing opcode 0x71 at 0x000a
VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
Could not find method java.nio.file.Files.newInputStream, referenced from method okio.Okio.source
答案 0 :(得分:3)
清单条目不正确。它们区分大小写。试试这些:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
如果这不能解决问题,可能会出现连接问题 - 可能是防火墙或代理损坏。
您可以在毕加索通过创建Picasso.Builder
并设置listener
来检索图片时记录错误。
Picasso.Builder builder = new Picasso.Builder(getApplicationContext());
builder.listener(new Picasso.Listener() {
@Override
public void onImageLoadFailed(Picasso arg0, String arg1) {
Log.e("Picasso Error", "Failed to load image: " + arg1);
}
});
Picasso pic = builder.build();
pic.load("http://static1.gamespot.com/uploads/original/1550/15507091/2867734-7512874458-CAK00.jpg")
.error(R.drawable.error)
.placeholder(R.drawable.placeholder)
.into(imageView);
使用该代码运行,您应该在logcat中看到连接错误。