1

I generated my application APK file. now, when im trying to open it via my device, im getting :

5474-5474/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.android.packageinstaller, PID: 5474
    java.lang.OutOfMemoryError
            at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
            at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
            at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
            at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
            at android.content.res.Resources.loadDrawable(Resources.java:2150)
            at android.content.res.Resources.getDrawable(Resources.java:715)
            at com.android.packageinstaller.PackageUtil.getAppSnippet(PackageUtil.java:181)
            at com.android.packageinstaller.InstallAppProgress.initView(InstallAppProgress.java:248)
            at com.android.packageinstaller.InstallAppProgress.onCreate(InstallAppProgress.java:182)
            at android.app.Activity.performCreate(Activity.java:5275)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
            at android.app.ActivityThread.access$800(ActivityThread.java:139)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5105)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
            at dalvik.system.NativeStart.main(Native Method)

please please help me... what did I do wrong?

Josef
  • 442
  • 7
  • 16
michal
  • 21
  • 1
  • look at this answer http://stackoverflow.com/questions/27549232/outofmemory-recycle-images/27555881#27555881 – Josef Dec 28 '14 at 17:29
  • Thank you ! It seems that the problem was pretty simple, the icon Image was to big.... – michal Dec 30 '14 at 07:31

1 Answers1

1

Android allocates 4 bytes per pixel for the image. Add to that the fact that if the icon is in drawable, android allocates additional resources to scale it up.

Android would also have limitations on how much memory it can allocate to the icon while installing the app. If the icon is too big, the app will run out of memory.

Solution - Follow the icon design guidelines here for adaptive or here for legacy. If you don't want to go into the complexities, just reduce your icon size and your app will work.

Abhinav Manchanda
  • 6,546
  • 3
  • 39
  • 46