gpt4 book ai didi

android - 无法使用 picasso 加载图像

转载 作者:行者123 更新时间:2023-11-29 15:49:04 28 4
gpt4 key购买 nike

我的代码:

  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);

还在 list 中添加了所需的权限

<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

最佳答案

list 条目不正确。它们区分大小写。试试这些:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

如果这不能解决问题,则可能存在连接问题 - 可能是防火墙或损坏的代理。

通过创建 Picasso.Builder 并设置 listener,您可以在 Picasso 检索图像时记录错误。

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 中看到连接错误。

关于android - 无法使用 picasso 加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31449659/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com