Search code examples
javaandroidandroid-studioandroid-sdcard

Why does the application work on API 19, but does not work on API 26? Target API 28


Why does the application work on API 19, but does not work on API 26? Target API 28

Logcat:

  2018-10-24 23:09:57.577 10744-10744/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.guahoo.tarotoftheday17, PID: 10744
java.lang.OutOfMemoryError: Failed to allocate a 196247420 byte allocation with 4194304 free bytes and 130MB until OOM
    at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
    at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:620)
    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455)
    at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1155)
    at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:720)
   .....and further

Solution

  • Did you used images in your app? The error is that it is take a lot of memory while you don't have enogh memory on your device or emulator? To solve the image problem compress image size then use it. And it will work