0

I have a workable codes that uses ImageView in the layout. The application could be run successfully before I restart my Eclipse. After that, my application crash whenever I uses the particular image. I tried replacing the image with another image, and it could run successfully. The image that caused my app to crash has a dimension of 608 x 2964 and it is a PNG file.

Can someone tell me what is wrong? I don't really understand what is written in the LogCat because I am new in Android. Appreciate it if someone could help me. Thanks.

Here is the link to my LogCat : http://pastie.org/pastes/5053152/text?key=zg7tbpuj9zqvlje4v6aczq

This is my ImageView.

<ImageView
android:contentDescription="@string/image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"     
android:layout_marginBottom="10dp" 
android:adjustViewBounds="true"
android:src="@drawable/about_mj" 
android:layout_gravity="center_horizontal"/>
Honey H
  • 299
  • 1
  • 6
  • 23

4 Answers4

1

http://developer.android.com/training/camera/photobasics.html#TaskScalePhoto

and

http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

will help you alot

WillingLearner
  • 739
  • 6
  • 10
  • Thank you. I will give it a try and then pick the best answer. By the way, all I did is setContentView to the layout that contained this large image. So could I use the Bitmap method to solve this problem? – Honey H Oct 14 '12 at 15:38
  • Yes you should. large bitmaps should be handled through code. – WillingLearner Oct 14 '12 at 15:44
  • Another possible situtation is you placed your image in the mdpi folder and called it in a xhdpi phone/emulator. this will scale the bitmap size to 200% – WillingLearner Oct 14 '12 at 16:53
  • thanks for the hint. i definitely placed my image in the wrong folder. i placed my image in the hdpi folder and called it in a xhdpi phone/emulator. the problem is solved when i transferred the image to the hdpi folder. thanks @WillingLearner for your help :) Also, thanks everyone for your response, and I will use the links given to me to help me if i ever encounter the same problem. :) – Honey H Oct 15 '12 at 02:25
0

It is clearly visible from log that your image is to large and causing

java.lang.OutOfMemoryError: bitmap size exceeds VM budget

Optimize your image.

Igor B.
  • 1,134
  • 9
  • 6
0

Looks like the follwing error is the problem

java.lang.OutOfMemoryError: bitmap size exceeds VM budget

Take a look at the follwing post. It has multiple possible solutions to fix this problem: java.lang.OutOfMemoryError: bitmap size exceeds VM budget - Android

Community
  • 1
  • 1
Jap Mul
  • 17,398
  • 5
  • 55
  • 66
0

Yes it shows OutOMemoryError and it shows inflateException in XML(Layout) file at line number 44. I think you are using some drawable in layout which may not get properly assigned values.

And_dev
  • 179
  • 1
  • 5
  • 16