peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
09/26/13 05:08 AM (11 years ago)

Android 3.0: app crashes in emulator OutOfMemoryError

I'm testing a 3.0 app in the emulator (Nexus S). After I navigate back and forth from a few "Menu With Image" and "Menu Simple" screens, the app crashes. I increased the memory of my emulator to 10000 just to see if that made a difference, and it still crashes. I haven't got to any content in the app yet (like a PDF or video), just going back and forth in some of the menu screens. Shortly before the crash, the LogCat shows a message about "Forcing Collection of SoftReferences", and then it shows the out of memory error and crashes. I was trying to find a good path to reproduce, and it seems if I tap from tab to tab it seems fine, it's more when I go into the menus, back out, and repeat - crashes within a minute. I had a friend install the app on his phone (a good friend :), and the same thing happened to him. I've double-checked all my setup settings, and I'm not sure what else to try.
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
09/26/13 06:54 AM (11 years ago)
@peterj: 1. What is the ram of your computer? (2GB, 8GB...) 2. Are you able to test this on a physical Android device? Jake
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
09/26/13 07:01 AM (11 years ago)
The computer is a mac running OS 10.8.5, 4 GB memory, latest ADT (downloaded yesterday) installed. I did install the app on a Motorola Droid - it crashes there too.
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
09/26/13 08:30 AM (11 years ago)
I was able to reproduce much easier just now: I went back and forth from a tab that loads a MenuWithImage, and pressing an item that goes to a MenuSimple - just back and forth like that made it crash within a minute. I'm looking through LogCat again, and just speculating - could it have to do with the size of the image used in the MenuWithImage plugin? I've found a couple other forum postings, and one on stackoverflow about image handling. My images are the size required by the plugin documentation, and the file size is quite small (67kb). However, my LogCat shows right after the OutOfMemory error there are messages about creating bitmaps, so I'm just wondering if there is a relationship. It certainly must have something to do with these plugins, right? - beacuse I'm only accessing these screens when it crashes...
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
09/26/13 09:43 AM (11 years ago)
The size of the header image for the Menu with Image plugin should be 960x640 as opposed to 1536x720 for android. The 1536x720 is good for ipad. There is also a default image which comes with this plugin named something menuimageabstractblue.png. Try deleting this image file from drawable folder and then rerun your app in emulator. It should work perfectly. Out of memory error is caused due to the bitmaps heap which your device or emulator is not able to handle due to large image file. This should help you in running your app perfectly.
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
09/26/13 10:52 AM (11 years ago)
Thank you for your response, Sandeep! Still having trouble, though. I deleted the abstractblue.png that was there. I then replaced the one I had with one resized to 960x640. I cleaned the project and ran it in the emulator. It still crashed within a minute, but with a different error: IllegalStateException: could not find a method headerOnClick(View) in the activity class com.myapp.BT_activity_host for onClick handler on view class android.widget.ImageView with id 'headerImageView' Additionally, the size you suggested isn't the same aspect ratio as the original - so there were white bars on either side of the image. I tried making on 960 wide that fit the same aspect ratio, and that crashed too.
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
09/26/13 10:57 AM (11 years ago)
Open up the layout file named wb_screen_menuimage.xml from the res-->layout folder and then deleted the following line form it- android:onClick="headerOnClick" Deleting the above line of code should solve your IllegalStateException error. Other than that try playing with the size of the image till it fits in proper aspect ratio like 960x480 0r 640x360.
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
09/26/13 01:01 PM (11 years ago)
Thanks Sandeep - that did seem to take care of the IllegalStateException crash. I also found in another forum post how to basically "hide" the image altogether, and I tried that along with deleting the actual image from the project. The app didn't crash then either, and performed a little better. I'll keep playing around, but I might just go with setting the image to be "hidden" on Android. I'm nervous about the crashing, and I'd like the performance to be as fast as possible. Thanks very much for your help!
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
11/06/13 08:02 AM (11 years ago)
I am seeing a very similar problem. My circumstances are a similar, but not exactly the same. I am using the circleview menu as my home page and if I click to a advanced menu with image page and back a couple of times, I get an out of memory message and the app crashes. I've just upgraded to 2.1.9, the same app was running OK when I was on 2.1.8. I've disabled the header graphic (temporarily I hope), I've deleted the android:onClick="headerOnClick" that is in the advanced menu with image, but the app still crashes. Did you ever get to the bottom of this @peterj?.
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
11/06/13 09:12 AM (11 years ago)
Removing that "header" line as Sandeep suggested, along with resizing my graphic reduced my crashes to about 0. I think I had 1 or 2 out of hundreds of replication attempts. Also, I never observed a crash on an actual device; it was always in the emulator, so I also thought it might have to do with a combination of code and the environment of my emulator.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.