我正在写一个应用程序,从一个网址加载图片,并显示在一个图像视图。这是代码。
public class MainActivity extends Activity {
private Picasso picasso;
private OkHttpClient okHttpClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageview = (ImageView) findViewById(R.id.imageView);
String image_url ="http://www.empireonline.com/images/uploaded/wreck-it-ralph-box-office.jpg";
okHttpClient = new OkHttpClient();
picasso = new Picasso.Builder(this)
.downloader(new OkHttpDownloader(okHttpClient))
.build();
Context con = getApplicationContext();
picasso.with(con)
.load(image_url)
.placeholder(R.drawable.ic_launcher)
.resize(60,60)
.into(imageview);
}应用程序不会崩溃,但也不会显示图片!在LogCat中,我得到了以下两个错误:
09-15 13:17:17.419 2358-2358/**************** E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache
09-15 13:17:17.439 2358-2358/**************** E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints()我使用的是Genymotion 2.0.1。你能帮我吗?
发布于 2014-09-27 19:26:14
我最终通过添加正确的JAR文件修复了代码!请确保您拥有以下库:
1- OKHTTP-2.0.0
2- OKHTTP-urlconnection-2.0.0 (不是RC1版本!)
3- Okio 1.0.1
4-毕加索-2.3.4
如果您使用这些库,GradienCache错误将被作为异常处理,并且您将不再获得强制关闭!
发布于 2014-09-16 03:28:47
我也遇到过类似的问题。我通过增加虚拟机的内存解决了这个问题。Genymotion中的默认设置非常小。
打开您的VirtualBox管理器(不是Genymotion)。选择您想要的Android VM,然后转到Settings / System并更改Base Memory的滑块。您还可以在Display选项卡中增加视频内存。

发布于 2015-10-08 02:18:14
也可以试试这个
Genymotion >设置>其他>清除缓存
这对我很管用
https://stackoverflow.com/questions/25849392
复制相似问题