Android package buildConfiapk
Copyright notice: This article is the blogger’s original article, shall not be reproduced without the permission of the blogger.
- First let’s see which directory buildConfig is in. One is the debug environment and the other is generated when you package apK
The release of the official environment buildConfig, which I’m doing here for comparison, is all generated.
Debug buildConfig
/ * * * Automatically generated file. DO NOT MODIFY * has explained the this file is Automatically generated, don't change it * / package com. Simple. Buildconfidemo; public final class BuildConfig { public static final boolean DEBUG = Boolean.parseBoolean("true"); public static final String APPLICATION_ID = "com.simple.buildconfidemo"; public static final String BUILD_TYPE = "debug"; public static final String FLAVOR = ""; public static final int VERSION_CODE = 1; Public static final String VERSION_NAME = "1.0"; }Copy the code
Buildconfig in the release environment
/**
* Automatically generated file. DO NOT MODIFY
*/
package com.simple.buildconfidemo;
public final class BuildConfig {
public static final boolean DEBUG = false;
public static final String APPLICATION_ID = "com.simple.buildconfidemo";
public static final String BUILD_TYPE = "release";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
}Copy the code
- We run apK in different environments separately and log in the program entry
Log.d("simple",BuildConfig.BUILD_TYPE)Copy the code
Release official environment
Debug Test Environment
- Buildconfig. DEBUG: builde_type = builde_type; buildconfig. DEBUG: builde_type = builde_type; builde_type = builde_type; builde_type = builde_type; builde_type = builde_type; Do you get a new skill in a flash, so you don’t have to make changes in the code, if you have to modify a lot of things every time you type a formal environment package, it is easy to have omissions, don’t ask me why I know!! Now all you have to do is pack!
Buildconfig nodes are all from Gradle nodes, and buildConfig custom nodes are all extensions of gradle nodes.
Android {compileSdkVersion 23 buildToolsVersion "23.0.2 defaultConfig {applicationId" com. Simple. Buildconfidemo" MinSdkVersion 9 targetSdkVersion 23 versionCode 1 versionName "1.0"} buildTypes {release {minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }Copy the code