0

When I try to use Glide to "open" images from url, it gives me error. Error in the logcat

Here's my code :

 String a = "https://i.imgur.com/v0PuwCG.png";

home_ib1_24_hours_to_live = (ImageButton)findViewById(R.id.home_ib1_24_hours_to_live);
    Glide.with(Home.this)
            .load(a)
            .centerCrop()
            .fitCenter()
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .into(home_ib1_24_hours_to_live);     


<ImageButton
            android:id="@+id/home_ib1_24_hours_to_live"
            android:layout_width="98dp"
            android:layout_height="155dp"
            android:background="@android:color/transparent"
            android:scaleType="fitCenter" />

And there are many more of these....

error

Zoe
  • 27,060
  • 21
  • 118
  • 148
Tamas
  • 11
  • 2
  • Paste the error that you are getting in the log – Asutosh Panda Jan 10 '18 at 18:01
  • added in the edit tab. – Tamas Jan 10 '18 at 18:31
  • You are getting an Out of Memory exception. It looks like whatever device you're running on is broken in some way considering it says you have -1662KB until OOM. One cannot have negative memory... If it's an emulator, you might have some configuration issues with memory. Also, you're setting two different scaleTypes in the Glide chain. – aProperFox Jan 10 '18 at 18:59
  • I'm using a real device instead of emulator. – Tamas Jan 10 '18 at 20:10
  • So what can I do now? – Tamas Jan 10 '18 at 20:17
  • This image is only 1.7 MB and also Glide does optimization for memory and performance. So this image size shouldn't be any problem. Check if you are having any memory leak or using other heavy resources in other areas of your App. Or try resizing the image size using Glide. See - https://stackoverflow.com/questions/46114603/resize-images-with-glide-in-a-imageview-android – Asutosh Panda Jan 11 '18 at 04:42

0 Answers0