应用程序在启动时意外停止 - Eclipse中没有编译错误

时间:2011-08-04 14:27:48

标签: android eclipse crash

我的Android应用程序(API级别8+)在Eclipse中编译时没有任何错误消息。

控制台说:

[2011-08-04 16:10:50 - PROJECT_NAME] Android Launch!
[2011-08-04 16:10:50 - PROJECT_NAME] adb is running normally.
[2011-08-04 16:10:50 - PROJECT_NAME] Performing PACKAGE_NAME.MainActivity activity launch
[2011-08-04 16:10:52 - PROJECT_NAME] Uploading PROJECT_NAME.apk onto device '80A354043048365763'
[2011-08-04 16:10:52 - PROJECT_NAME] Installing PROJECT_NAME.apk...
[2011-08-04 16:10:55 - PROJECT_NAME] Success!
[2011-08-04 16:10:55 - PROJECT_NAME] Starting activity PACKAGE_NAME.MainActivity on device DEVICE_ID
[2011-08-04 16:10:56 - PROJECT_NAME] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=PACKAGE_NAME/.MainActivity }

这就是那里总是显示的东西。然后,在我的USB连接的Android设备上启动该应用程序。

过去工作正常,直到在开发过程中的某个时刻出现以下信息:。

Sorry! The application Messages (process PACKAGE_NAME) has stopped unexpectedly. Please try again. Force close.

在后台,有应用程序窗口 - 但没有任何GUI元素:没有按钮,没有文本。只是应用程序的标题在顶部。

我不知道为什么会出现此消息。我不能再测试我的应用程序了。而且 - 正如我已经说过的那样 - Eclipse中没有错误。

Logcat说:

08-04 16:35:27.666: INFO/ActivityManager(2365): Force stopping package PACKAGE_NAME uid=10077
08-04 16:35:27.676: INFO/ActivityManager(2365): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=PACKAGE_NAME/.MainActivity }
08-04 16:35:27.726: WARN/Flex(2448): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:27.766: INFO/ActivityManager(2365): Start proc PACKAGE_NAME for activity PACKAGE_NAME/.MainActivity: pid=4262 uid=10077 gids={3003}
08-04 16:35:27.916: WARN/ActivityThread(4262): Application PACKAGE_NAME is waiting for the debugger on port 8100...
08-04 16:35:27.926: INFO/System.out(4262): Sending WAIT chunk
08-04 16:35:28.016: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:28.016: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:28.016: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:28.016: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:28.016: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] 0. mDataNetType: 2
08-04 16:35:28.016: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] curNetwork=26203 curHPLMN=26203
08-04 16:35:28.126: INFO/System.out(4262): Debugger has connected
08-04 16:35:28.136: INFO/System.out(4262): waiting for debugger to settle...
08-04 16:35:28.336: INFO/System.out(4262): waiting for debugger to settle...
08-04 16:35:28.536: INFO/System.out(4262): waiting for debugger to settle...
08-04 16:35:28.736: INFO/System.out(4262): waiting for debugger to settle...
08-04 16:35:28.936: INFO/System.out(4262): waiting for debugger to settle...
08-04 16:35:29.141: INFO/System.out(4262): waiting for debugger to settle...
08-04 16:35:29.336: INFO/System.out(4262): waiting for debugger to settle...
08-04 16:35:29.539: INFO/System.out(4262): waiting for debugger to settle...
08-04 16:35:29.739: INFO/System.out(4262): waiting for debugger to settle...
08-04 16:35:29.945: INFO/System.out(4262): waiting for debugger to settle...
08-04 16:35:30.146: INFO/System.out(4262): debugger has settled (1340)
08-04 16:35:31.016: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:31.016: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:31.016: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:31.016: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:31.026: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] 0. mDataNetType: 2
08-04 16:35:31.026: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] curNetwork=26203 curHPLMN=26203
08-04 16:35:34.016: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:34.016: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:34.016: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:34.016: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:34.026: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] 0. mDataNetType: 2
08-04 16:35:34.026: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] curNetwork=26203 curHPLMN=26203
08-04 16:35:37.016: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:37.016: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:37.016: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:37.016: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:37.026: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] 0. mDataNetType: 2
08-04 16:35:37.026: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] curNetwork=26203 curHPLMN=26203
08-04 16:35:37.697: WARN/ActivityManager(2365): Launch timeout has expired, giving up wake lock!
08-04 16:35:37.894: WARN/ActivityManager(2365): Activity idle timeout for HistoryRecord{451e5930 PACKAGE_NAME/.MainActivity}
08-04 16:35:40.016: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:40.016: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:40.016: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:40.016: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:40.026: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] 0. mDataNetType: 2
08-04 16:35:40.026: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] curNetwork=26203 curHPLMN=26203
08-04 16:35:43.017: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:43.017: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:43.017: WARN/Flex(2365): getString FLEX_COUNTRY_CODE COM
08-04 16:35:43.017: WARN/Flex(2365): getString FLEX_OPERATOR_CODE OPEN
08-04 16:35:43.026: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] 0. mDataNetType: 2
08-04 16:35:43.026: DEBUG/StatusBarPolicy(2365): [BRIGHTHY] curNetwork=26203 curHPLMN=26203

我希望有人可以帮助我...... :)我几乎绝望了。非常感谢你提前!

编辑#1:

当我在Eclipse的调试模式下运行应用程序时,不会出现错误消息。出现应用程序窗口但没有任何GUI元素。我必须使用HOME按钮关闭窗口。 BACK按钮不起作用。在应用程序设置中,我可以选择“强制停止”。那么线程有什么问题吗?也许申请被卡住了?

编辑#2:

它似乎不是Eclipse问题或手机问题,因为我仍然可以创建一个“Hello World”应用程序。它甚至可以在手机上运行。

编辑#3:

我的主要活动开始如下:

public class MainActivity extends ListActivity {

当我将其更改为...

public class MainActivity extends Activity {

...并注释掉以下行,显示的应用程序没有任何错误消息:

setListAdapter(this.m_adapter);

编辑#4:

我想我可以再次记住我在第一次出现问题之前所做的更改:我实现了tutorial on ListViews的代码,该代码运行良好。但后来我将listview的ID(参见tutorial:main.xml)从“android:list”更改为“resultList”。所以这可能是原因。

当我现在更改它时,错误发生在initiateSearch()中,其中说明了thread.notifyAll();

当我注释掉这一行时,一切都没有任何错误,但当然,应用程序不再应该做什么了。

1 个答案:

答案 0 :(得分:4)

与Marco谈过后发现错误与xml中List元素的id命名有关。

http://developer.android.com/reference/android/app/ListActivity.html - “...要做到这一点,你自己的视图必须包含一个名为'@ android:id / list'的ListView对象......”


Eclipse有时候有点垃圾!!

我会按顺序尝试:

  1. 清理项目
  2. 重启Eclipse
  3. 完全删除应用程序和数据&手机缓存
  4. 在手机上进入您的设置 - >应用 - >开发并禁用然后重新启用USB调试
  5. 重新启动手机
  6. 重建您的eclipse工作区
  7. 如果有任何帮助,请告诉我