Android Buildconfig Use

Source: Internet
Author: User

A new feature has been added to ADT (R17) that allows developers to allow only certain code in debug mode. The build system generates a class named Buildconfig that contains a debug constant that automatically sets the value based on your build type. You can use the (Buildconfig.debug) constant to write code that runs only in DEBUG mode.

If some code does not want to be executed after publishing, you can use this feature.

such as debug logs, you do not want to be seen by other developers after the release of software, the past is that you set a global variable, marking the software for debug mode or Release mode.

[Java]

    1. Public   static boolean DEBUG = true;

Then write in the code

[Java]

    1. if (debug==true) {
    2. LOG.D (TAG,"output Something");
    3. }

It is time-consuming to modify the value of the debug variable before packaging the release, sometimes not remembering to recompile the release.

With Buildconfig.debug, you can write directly in the code

[Java]

    1. <span style="White-space:pre"> </span> if (buildconfig.debug) {
    2. LOG.D (TAG, "output Something");
    3. }

Before the release,

[Java]

    1. The value of Buildconfig.debug is automatically true,

You're in a package released through the Android Tools, Export signed application pack,

[Java]

    1. The value of the buildconfig.debug automatically becomes false.

[Java]

    1. The developer doesn't have to change anything else himself.

Android Buildconfig Use

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.