Android emulator debugging error: black screen

I found the problem while I was trying to debug the following code:

package course.examples.theanswer; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class TheAnswer extends Activity { public static final int[] answers = { 42, -10, 0, 100, 1000 }; public static final int answer = 42; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.answer_layout); TextView answerView = (TextView) findViewById(R.id.answer_view); int val = findAnswer(); String output = (val == answer) ? "42" : "We may never know"; answerView.setText("The answer to life, the universe and everything is:\n\n" + output); } private int findAnswer() { for (int val : answers) { if (val == answer) return val; } return -1; } 

}

I inserted a breakpoint in the line "int val = findAnswer();" , that is, before the application executes the message ("Answer to life ..."). So, the emulator shows a white screen with a title, right, but when it goes about 10 seconds, the screen turns black ... and logCat shows the following message:

 01-23 05:57:29.995: I/System.out(2009): waiting for debugger to settle... 01-23 05:57:30.205: I/System.out(2009): debugger has settled (1309) 01-23 05:57:30.845: D/dalvikvm(2009): threadid=1: still suspended after undo (sc=1 dc=1) 01-23 05:57:37.825: W/ActivityManager(1254): Launch timeout has expired, giving up wake lock! 01-23 05:57:37.835: E/WindowManager(1254): Starting window AppWindowToken{b33e2a00 token=Token{b3344b58 ActivityRecord{b317b130 u0 course.examples.theanswer/.TheAnswer t10}}} timed out 

The final message is when the screen goes black. I canโ€™t send images, but the emulator only shows: hour, network and battery. Also, if I clicked the "resumen" button, the application phishes perfectly. However, I think this is not an idea. He must stop on a white screen to debug ... (I think, but I'm not sure). This is normal?

Can anybody help me?

thanks

+7
android debugging eclipse emulation
source share
1 answer

The explanation is simple, but I do not know how to change this behavior:

When the Android application is running, the main thread should process all incoming messages (from the GUI and other internal messages). It is strictly forbidden to use the main thread for lengthy operations, because at this time the thread is blocked and cannot process messages.

When you launch the application, Android brings 10 seconds to the application to launch. Subsequently, he expects the application to process messages.

Now to your problem:

You set a breakpoint in the onCreate (..) method, which is called by the main thread - a thread that should not be blocked. Setting a breakpoint is nothing more than interrupting / blocking a thread until you click resume. Therefore, after 10 seconds, the Android system (which is not affected by your debugger) expects the application to complete with launch. But the main thread is still trapped from the breakpoint! Therefore, Android believes that the application could not start and ceased to be responsible for part of the responsibility for the graphical interface.

The only solution I see is to disable this โ€œLaunch Timeoutโ€, however I do not know how and how it is possible.

+5
source share

All Articles