Does Android determine whether to develop debug mode or Release mode _android

Source: Internet
Author: User

As shown below:

public class Logutils {public

	static Boolean app_dbg = FALSE;/is debug mode public
	
	static void init (Context conte XT) {
		app_dbg = isapkdebugable (context);
	}
	
	/**
	 * But when we don't set its Debug property in Androidmanifest.xml:
	 * Its Debug property is true when packaged with eclipse running this way. The Debug property is False when you use eclipse export this way to package.
	 * When you use Ant to package, the value depends on whether the ant packaging parameter is release or Debug.
 	 * Therefore, it is best not to set the Android:debuggable attribute in the Androidmainifest.xml, but to decide its value by the packaging method.
	 * 
	 @param context
	 * @return
	 * @author shanhy
	 * @date 2015-8-7
	/public static Boolean isapkdebugable (Context context) {
    try {
      applicationinfo info= context.getapplicationinfo ();
        Return (info.flags&applicationinfo.flag_debuggable)!=0;
    } catch (Exception e) {
      
    } return
    false;
  }
	
}

In project development, we output the log according to the debug attribute.

But there are times when we want to print out the release version that is installed on the company's test machine, so this time we go to the application tag in Androidmanifest.xml to add the attribute force setting debugable, as follows:

<application android:debuggable= "true" tools:ignore= "Hardcodeddebugmode" ...
.
.../>

The Init method executes in the OnCreate method of the first activity of the client.

The above Android judgment is to develop the debug mode, or Release mode is the way to distribute the whole content of the small series, I hope to give you a reference, but also hope that we support cloud habitat community.

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.