When debugging a program, the output of the parameter is helpful for us to understand whether the entire program operates according to our own logic.
Java programs under the Android platform have many ways to output information in the console:
1. System.out.println ("... ");
2. Android.util.Log ("... ");
Now, we're going to separate these two inputs to see how we can get the content out of our relationship, the rest of the output, and we'll just disappear to the other side of the world.
I. Writing code:
First, take a look at my Java program:
[Python]
Package WYF.ZCL;
Import android.app.Activity;
Import Android.os.Bundle;
Import Android.util.Log;
public class MyActivity extends activity {
/** called the activity is a. */
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
System.out.println ("the System.out.println");
LOG.D ("tag", "The" "a");
}
}
Package WYF.ZCL;
Import android.app.Activity;
Import Android.os.Bundle;
Import Android.util.Log;
public class MyActivity extends activity {
/** called the activity is a. */
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
System.out.println ("the System.out.println");
LOG.D ("tag", "The" "a");
}
which
System.out.println ("the System.out.println");
LOG.D ("tag", "The" "a");
The above two lines are examples of our current test.
(Actually, I downloaded an example on the Internet and then imported the steps to import the project file and put it in the final lecture.) )
Two. Open the Eclipse Debugger (DDMS):
1. Open eclipse, in the upper-left corner of the interface, see a plus, mouse move up, will show "Open Perstective", click on:
See the red part of the picture, in the Open dialog box has a < DDMS > options, selected, click "OK", the program will automatically jump to the DDMS debugger main interface.
In the open Ddms interface, we mainly care about the red circle, the "Logcat" and the "+" button below.
Three. Configure the Eclipse Debugger (DDMS):
Click the "+" button under the Logcat tab of the DDMS main interface, this is the filter setting for our information output, and my configuration is as follows:
Then click Run to see the output effect as follows:
So it's going to output the information we just want to see.
===========================================================================================
Logging problem: How do I import an existing project into eclipse?
Solution: Open Eclipse, "File"-->> "Import ..."-->> "Existing Projects into WorkSpace".
Log problem: Prompts Android requires compiler compliance level 5.0 or 6.0. Found ' 1.7 ' instead. Use the Android Tools > Fix Project Properties.
Solution: Project Right key-->> "Android Tools"-->> "Fix Project Properties". Run again, if still not, check Project->properties->java Compiler, confirm
The Compiler compliance level is set to 1.7 and the enable specific seetings.