【问题标题】:Hangup in ActivityThread?在 ActivityThread 中挂断?
【发布时间】:2011-05-15 18:28:57
【问题描述】:

当我尝试在 Eclipse 中调试我的 Android 应用程序时,有什么线索会挂在这个代码块上吗?

public static final int REMOVE_PROVIDER         = 131;

--

package com.example.myapp;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class TEHWARRiORS extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, Start.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("Start").setIndicator("",
                          res.getDrawable(R.drawable.ic_tab_navbar_admins))
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, Servrar.class);
        spec = tabHost.newTabSpec("Servrar").setIndicator("Servrar",
                          res.getDrawable(R.drawable.ic_tab_navbar_admins))
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, Admins.class);
        spec = tabHost.newTabSpec("Admins").setIndicator("Admins",
                          res.getDrawable(R.drawable.ic_tab_navbar_admins))
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, Regler.class);
        spec = tabHost.newTabSpec("Regler").setIndicator("Regler",
                          res.getDrawable(R.drawable.ic_tab_navbar_admins))
                      .setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(0);

    }
}

--

05-15 20:46:09.969: ERROR/AndroidRuntime(15352): FATAL EXCEPTION: main
05-15 20:46:09.969: ERROR/AndroidRuntime(15352): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testapp/com.example.testapp.TEHWARRiORS}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testapp/com.example.testapp.Start}: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.ActivityThread.access$1500(ActivityThread.java:132)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.os.Looper.loop(Looper.java:143)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.ActivityThread.main(ActivityThread.java:4196)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at java.lang.reflect.Method.invokeNative(Native Method)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at java.lang.reflect.Method.invoke(Method.java:507)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at dalvik.system.NativeStart.main(Native Method)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testapp/com.example.testapp.Start}: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1651)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:656)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.widget.TabHost.setCurrentTab(TabHost.java:326)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.widget.TabHost.addTab(TabHost.java:216)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at com.example.testapp.TEHWARRiORS.onCreate(TEHWARRiORS.java:28)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     ... 11 more
05-15 20:46:09.969: ERROR/AndroidRuntime(15352): Caused by: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.TabActivity.onContentChanged(TabActivity.java:105)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:227)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.Activity.setContentView(Activity.java:1702)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at com.example.testapp.Start.onCreate(Start.java:11)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     ... 20 more
05-15 20:46:21.539: ERROR/SurfaceFlinger(1328): layer=0x19971f8 is not in the purgatory list

【问题讨论】:

  • 并非没有更多信息。你是什​​么意思'挂'?
  • 它会一直等到我按“恢复”来恢复调试。但是,它只会导致应用崩溃。
  • logcat 崩溃时的内容是什么?
  • 我不确定这是否有趣,但这可以在 LogCat:05-15 20:33:10.449: ERROR/SurfaceFlinger(1328): layer=0x4ca858 is not in the炼狱名单
  • 听起来你在那里设置了一个断点——你可能想试试Remove all breakpoints。但是,这似乎更有可能:stackoverflow.com/questions/723199/…

标签: java android


【解决方案1】:

好吧,你去:

05-15 20:46:09.969: ERROR/AndroidRuntime(15352): Caused by: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
05-15 20:46:09.969: ERROR/AndroidRuntime(15352):     at android.app.TabActivity.onContentChanged(TabActivity.java:105)

您正在使用 TabActivity,但已将其内容替换为没有标签宿主的内容。

【讨论】:

  • 糟糕,我觉得自己很愚蠢。我使用 TabActivity 而不是 Activity。包 com.example.testapp;导入android.app.Activity;导入android.os.Bundle; public class Start extends Activity { /** 首次创建活动时调用。 */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);设置内容视图(R.layout.start); } }
【解决方案2】:

好的,所以这里给出了(可能对你不太有用)为什么它“挂起”的答案(我认为它的行为就像在那里设置了一个断点):Why does my Eclipse project have phantom debugger breakpoints?。您可以通过取消选择Window > Preferences > Java > Debug : Suspend execution on uncaught exceptions来关闭它

至于导致此Suspend execution on uncaught exceptions 的异常是什么,应该在日志中以及堆栈跟踪中可见 - 您应该编辑您的问题并发布。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 2014-10-01
    • 2012-03-22
    • 1970-01-01
    • 2020-08-14
    • 1970-01-01
    相关资源
    最近更新 更多