简体   繁体   English

java.lang.RuntimeException:无法启动活动

[英]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. 我有一个不寻常的问题,我有一个简单的活动,其中包括9个带有背景图像和主布局背景的按钮。

I run my apps on my nexus one which is pretty fast, so i never had problem with the app. 我的应用程序运行在非常快速的nexus上,因此我从来没有遇到过问题。 Until i updated to Android 2.3.3. 直到我更新到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. 并且该应用程序运行正常,没有问题,结果证明我使用的图像太大,而android 2.3.3则比android 2.2慢一些。 So i used image.png rather than image.jpg, which solved the problem for nexus one phones. 因此,我使用image.png而不是image.jpg来解决一个手机的问题。 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. 由于映像过大,VM的内存不足。

Each app have 16MB of memory to play with, if you exceed 16MB the app will crash. 每个应用程序都有16MB的内存可玩,如果超过16MB,则该应用程序将崩溃。 Nexus one has 28MB of memory for each app. Nexus 1每个应用程序都有28MB的内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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