Android studio multi-channel packaging, formal debugging package, build. gradle Parsing

Source: Internet
Author: User

Android studio multi-channel packaging, formal debugging package, build. gradle Parsing
1. describes the build. gradle file. 1.1 root directory Android

1.1.1
DefaultConfig is the root directory of Android. You can configure the package name and other information. If AndroidMainfest. xml is also configured, use defaconfig config as the standard.
1.1.2
SigningConfigs is the root directory of Android. You can configure the signature, for example:

 

If you want to useFormal signature packageIt can be configured in buildType.

 

buildTypes {    debug {        signingConfig signingConfigs.release    }    release {        minifyEnabled false        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'    }}

 

1.1.3
Package Multiple channels to modify the meta-data value of AndroidMainFest.
Configure AndroidMainFest as follows:

 

$ {Value} is dynamically configured.

 

 

    
 

 

The configuration of build. gradle is as follows:

 

productFlavors {    huawei {        minSdkVersion 14        targetSdkVersion 21        manifestPlaceholders =[Value: huawei]    }    xiaomi {        minSdkVersion 14        targetSdkVersion 21        manifestPlaceholders =[Value: xiaomi]    }}

 

Get AndroidMainnifest Value in the code

 

// Obtain the meta field public static String getMetaString (Context con, String name) {ApplicationInfo ai = null; try {ai = con. getPackageManager (). getApplicationInfo (con. getPackageName (), PackageManager.GET_META_DATA);} Catch (PackageManager. NameNotFoundException e) {e. printStackTrace ();} Bundle bundle = ai. metaData; return bundle. getString (name );}

 

Use directly during packaging

 

 

Finally, paste the build. gradle file.

 

Apply plugin: 'com. android. application 'android {compileSdkVersion 21 buildToolsVersion 21.1.2 defaultConfig {applicationId caisheng.com. search minSdkVersion 16 targetSdkVersion 21 versionCode 1 versionName 1.0} signingConfigs {// your own keystore Information release {keyAlias 'aolaigo 'keypassword' 123456 'storefile file ('e:/test. jks ') storePassword '000000'} lintOptions {checkReleaseBuilds false // Or, if you prefer, you can continue to check for errors in release builds, // but continue the build even when errors are found: abortOnError false} buildTypes {debug {signingConfig signingConfigs. release} release {minifyEnabled false proguardFiles getdefadefaproguardfile('proguard-android.txt '), 'proguard-rules. pro'} productFlavors {huawei {minSdkVersion 14 targetSdkVersion 21 manifestPlaceholders = [Value: huawei]} xiaomi {minSdkVersion 14 targetSdkVersion 21 manifestPlaceholders = [Value: xiaomi] }}dependencies {compile fileTree (dir: 'libs', include :['*. jar ']) // compile (name: 'cai', ext: 'aar') // compile project (': cai')/* compile 'com. facebook. fresco: 0.6.0 'compile 'com. android. support: appcompat-v7: 22.2.0 'compile 'com. github. liuguangqiang. swipeback: library: 1.0.2 @ aar 'compute' com. sothree. slidinguppanel: library: 3.1.1 'compile 'me. dm7.barcode=: zbar: 1.5 '*/}

 

 

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.