简体   繁体   中英

java.lang.RuntimeException: Unable to start activity

I have an unusual problem, I have simple activity, which includes 9 buttons with background images and background to the main layout.

I run my apps on my nexus one which is pretty fast, so i never had problem with the app. Until i updated to Android 2.3.3. My app won't run and force closes. Then i deleted the code below,

this.getWindow().setBackgroundDrawableResource(R.drawable.image);

and the app ran fine with no problems, it turned out that the image that i was using was too big, and android 2.3.3 is somehow slower than android 2.2. So i used image.png rather than image.jpg, which solved the problem for nexus one phones. However the slower phones wont run my app still cause its taking too long to create the activity. So the main Thread is timing out causing the app to crash. What can i do in this case? Thanks...

I finally found the problem. The VM was running out of memory due to large size of the image.

Each app have 16MB of memory to play with, if you exceed 16MB the app will crash. Nexus one has 28MB of memory for each app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM