Debugging for Android applications

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.