The Android Studio-----cannot print---Log----issues summary----Huawei Pit Depth

Source: Internet
Author: User

problem Description: An Zuojin machine Debugging System.out.println cannot output, err can; log.e,w can, but others do not.

Workaround, look at the default settings log for the warn in the following way.

Cool Mobile: *20121220# into Android's general engineering mode, and then follow the log settings below to modify the phone's log default modeSummary (abstract)

Required skills, use the Log tool LogCat, and try to solve the problem of real machine debugging without logs.

Log tool (LogCat)

Logs play a very important role in the development of any project, and in Android projects you have to use the LogCat tool if you want to view the logs.

Find 6:android in the Status Bar at the bottom of Android Studio and click on her. Such as

LogCat appeared, as

    1. Choose Devices here, of course, generally do not need to choose, if only one device connected.
    2. Here, log level is selected. Includes: Verbose, Debug, Info, Warn, Error, Assert. The above levels are raised sequentially.
    3. The filter is selected here, and the default is to automatically generate a filter that is the package name is a filter for the project name.
Using LogCat

The Log tool class in Android is log (ANDROID.UTIL.LOG), which provides several ways for us to print the logs.

    1. LOG.V () corresponds to Verbose
    2. LOG.D () corresponds to Debug
    3. LOG.I () corresponding Info
    4. LOG.W () corresponds to Warn
    5. LOG.E () corresponds to Error
    6. LOG.WTF () Prints the execution path (the call stack) at this point in the code at the same time as the output log.

The introduction is over, let's play a little bit. Open helloworldactivity, add a line of print log statements in the Oncreat () method, in order to make the log obvious I added some underscores, as follows:

@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hello_world); Log.d("HelloWorldActivity","______________onCreate execute______________");}

LOG.D () method passed two parameters, the first parameter is tag, generally passed in the current class name is good, mainly used to filter the printing information. The second parameter is MSG, which is the specific content you want to print.

Now rerun the project, click the little green arrow in the toolbar, or press SHIFT+F10. After the program runs, the comrades who use the simulator may already be able to see the logs, such as

The use of the real machine comrades, may see or empty logcat. Need to do such a thing, the menu bar tools→android→enable ADB integration put this hook on and then run again.

Should I see the log this time? See if we can find the log information we want to print out. The filter must be selected App:com.xxxx.helloworld Oh. If there is a log, but can not find the log we want to print HelloWorldActivity: ______________onCreate execute______________ , then congratulations, you use the real machine looks like my high-end, is not what black technology.

Let's try to solve the problem.

    1. Is the developer option for the phone open, and is the USB debug turned on? Fix them and run again, can we find our logs? No, go to 2.
    2. Is there such information in could not disable core file generation for pid 3963: Operation not permitted the log? Yes, go to 3, no, I don't know how to do it, or you can paste the log in the comments and I'll see.
    3. Is it a Huawei mobile phone? Yes, go to 4, no, you can refer to 4 yourself Google Baidu a bit.
    4. Enter in dial-up interface: *#*#2846579#*#* go to the Test menu interface and
      Project menu→ background Settings →log settings
      Log switch →log turn on log level setting →verbose
      dump&log→ All selected
      Restart your phone and restart Android Studio.
      PS: Depending on the system version, there may be a slight difference.

Reboot complete, open Android Studio, run the project, this should be able to find our log. If you haven't found it, I'm sorry to wash up and sleep, I can only help here. (or you can change your phone)

Custom Filters (Filter)

Click the Filter drop-down box, select Edit Filter Configuration, and in the popup dialog box, click the plus sign in the upper left corner to create a new filter. Such as

The meaning is as follows:

    • Name:filter Name
    • By log tag: filter through the log tag
    • By log Message: Msg content filtering through the log
    • By package Name: Filter by packet name
    • By PID: Filter by PID
    • By log level: Filter by Log rank
    • Regex: Indicates that a regular expression can be used to match

The above filter conditions can be combined.

I built a filter for data, and the filter is that tag equals data. By selecting Filter as data, our log is missing because it does not match the log with the tag equal to data.

Now go and change the tag of our log in the OnCreate () method to data. As shown below:

LOG.D ("Data", "______________oncreate execute______________");

Then rerun, choose Filter as data, our log appears. Of course, there may be some weird logs also appear, carefully see the tag contains data.

An irrepressible curiosity

Look at the bottom of this Android Studio Status Bar and we find LogCat places like

Aren't you curious why there's a 6 in front of Android? Is it because of using LogCat your Android development level will be 666666666?

No matter what happens, I believe there is only one truth, such as:

OK, it's over.

http://blog.csdn.net/copy_yuan/article/details/51460718

Android Studio-----Unable to print---log----issues summary----Huawei Pit Depth (RPM)

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.