Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8087045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:38:55+00:00 2026-06-05T18:38:55+00:00

So I’m writing a piece of software and it keeps crashing when I try

  • 0

So I’m writing a piece of software and it keeps crashing when I try to create a second drawable. It starts out on the front screen, then I push a button and it goes to a new activity. On that activity I have an ImageView in the middle and a button on the bottom. When the activity loads there is a drawable in the ImageView. So when I click on the button at the bottom it is supposed to change the drawable that is in the ImageView but it crashes. I found errors in the LogCat that say things like:

E/AndroidRuntime(1385): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

So here is my code from that activity:

package com.foocity.android.gui;

import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

public class NewMapActivity extends Activity 
{
    public ImageView    mapPreview;
    public Drawable     currentPic;

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.newmap);

        currentPic = getResources().getDrawable(R.drawable.milestone_cleanenergy);
        mapPreview = (ImageView) findViewById(R.id.chooseCanvas);
        mapPreview.setImageDrawable(currentPic);
    }

    public void changePic(View view)
    {
        System.out.println("tester boy!!!!!!!!!!!");

        currentPic = null;
        currentPic = getResources().getDrawable(R.drawable.welcomescreen);
        mapPreview.setImageDrawable(currentPic);
    }
}

And here is what the LogCat says when it crashes:

06-13 21:25:56.613: D/dalvikvm(4086): GC_EXTERNAL_ALLOC freed 614 objects / 50072 bytes in 58ms
06-13 21:26:02.133: W/System.err(4086): java.io.FileNotFoundException: /sdcard/000.txt (No such file or directory)
06-13 21:26:02.143: W/System.err(4086):     at org.apache.harmony.luni.platform.OSFileSystem.openImpl(Native Method)
06-13 21:26:02.143: W/System.err(4086):     at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:152)
06-13 21:26:02.143: W/System.err(4086):     at java.io.FileInputStream.<init>(FileInputStream.java:82)
06-13 21:26:02.143: W/System.err(4086):     at java.util.Scanner.<init>(Scanner.java:188)
06-13 21:26:02.143: W/System.err(4086):     at java.util.Scanner.<init>(Scanner.java:167)
06-13 21:26:02.143: W/System.err(4086):     at com.foocity.android.Map.<init>(Map.java:33)
06-13 21:26:02.143: W/System.err(4086):     at com.foocity.android.FooCity.setMap(FooCity.java:594)
06-13 21:26:02.143: W/System.err(4086):     at com.foocity.android.gui.StartActivity.chooseMap(StartActivity.java:33)
06-13 21:26:02.153: W/System.err(4086):     at java.lang.reflect.Method.invokeNative(Native Method)
06-13 21:26:02.153: W/System.err(4086):     at java.lang.reflect.Method.invoke(Method.java:521)
06-13 21:26:02.153: W/System.err(4086):     at android.view.View$1.onClick(View.java:2067)
06-13 21:26:02.153: W/System.err(4086):     at android.view.View.performClick(View.java:2408)
06-13 21:26:02.153: W/System.err(4086):     at android.view.View$PerformClick.run(View.java:8816)
06-13 21:26:02.153: W/System.err(4086):     at android.os.Handler.handleCallback(Handler.java:587)
06-13 21:26:02.153: W/System.err(4086):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-13 21:26:02.153: W/System.err(4086):     at android.os.Looper.loop(Looper.java:123)
06-13 21:26:02.153: W/System.err(4086):     at android.app.ActivityThread.main(ActivityThread.java:4627)
06-13 21:26:02.153: W/System.err(4086):     at java.lang.reflect.Method.invokeNative(Native Method)
06-13 21:26:02.153: W/System.err(4086):     at java.lang.reflect.Method.invoke(Method.java:521)
06-13 21:26:02.153: W/System.err(4086):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-13 21:26:02.153: W/System.err(4086):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-13 21:26:02.153: W/System.err(4086):     at dalvik.system.NativeStart.main(Native Method)
06-13 21:26:02.393: D/dalvikvm(4086): GC_EXTERNAL_ALLOC freed 3101 objects / 159528 bytes in 53ms
06-13 21:26:07.113: I/System.out(4086): tester boy!!!!!!!!!!!
06-13 21:26:07.123: E/dalvikvm-heap(4086): 9469350-byte external allocation too large for this process.
06-13 21:26:07.123: E/GraphicsJNI(4086): VM won't let us allocate 9469350 bytes
06-13 21:26:07.133: D/AndroidRuntime(4086): Shutting down VM
06-13 21:26:07.133: W/dalvikvm(4086): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-13 21:26:07.143: E/AndroidRuntime(4086): FATAL EXCEPTION: main
06-13 21:26:07.143: E/AndroidRuntime(4086): java.lang.IllegalStateException: Could not execute method of the activity
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.view.View$1.onClick(View.java:2072)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.view.View.performClick(View.java:2408)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.view.View$PerformClick.run(View.java:8816)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.os.Handler.handleCallback(Handler.java:587)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.os.Looper.loop(Looper.java:123)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.app.ActivityThread.main(ActivityThread.java:4627)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at java.lang.reflect.Method.invokeNative(Native Method)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at java.lang.reflect.Method.invoke(Method.java:521)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at dalvik.system.NativeStart.main(Native Method)
06-13 21:26:07.143: E/AndroidRuntime(4086): Caused by: java.lang.reflect.InvocationTargetException
06-13 21:26:07.143: E/AndroidRuntime(4086):     at com.foocity.android.gui.NewMapActivity.changePic(NewMapActivity.java:30)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at java.lang.reflect.Method.invokeNative(Native Method)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at java.lang.reflect.Method.invoke(Method.java:521)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.view.View$1.onClick(View.java:2067)
06-13 21:26:07.143: E/AndroidRuntime(4086):     ... 11 more
06-13 21:26:07.143: E/AndroidRuntime(4086): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.graphics.Bitmap.nativeCreate(Native Method)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.content.res.Resources.loadDrawable(Resources.java:1709)
06-13 21:26:07.143: E/AndroidRuntime(4086):     at android.content.res.Resources.getDrawable(Resources.java:581)
06-13 21:26:07.143: E/AndroidRuntime(4086):     ... 15 more

It obviously has something to do with memory management, which I’m not use to monitoring with Java, but I’m not really sure what to do. Any help would be appreciated. Thanks

P.S. I realized as posting this that I tried something else (creating a file object and then writing it’s content to System.out) and it caused the same error even before the new activity loaded the first drawable in the ImageView so it must have everything to do with memory management, I guess I need help with how to manage memory in this system because I am used to the GC taking care of that in regular Java.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:38:56+00:00Added an answer on June 5, 2026 at 6:38 pm
    Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
    

    From this line it is evident that image you are trying to display is excessive size. Try to reduce the size of the image and see.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am writing an app with both english and french support. The app requests
I'm trying to create an if statement in PHP that prevents a single post
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I am writing an app for my school newspaper, which is run completely online

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.