Android Studio| app| build.gradle (4)

***********************************************

* app| build.gradle: 包重命名后,app| build.gradle也要相应的改,是改应用id,后台打印和应用区别用的是应用id号。

applicationId"com.iot.smartdemo"

//        applicationId"com.iot.usr_io88"

***********************************************

* app| build.gradle

indigo_devel| build.gradle

buildscript {

    repositories {

        mavenCentral()

    }

    dependencies {

        classpath 'com.android.tools.build:gradle:2.1.2'

        // NOTE: Do not place your applicationdependencies here; they belong

        // in the individual modulebuild.gradle files

    }

    apply from:"https://github.com/rosjava/android_core/raw/indigo/buildscript.gradle"

}

//apply plugin: 'catkin'

allprojects {

    group 'com.github.rosjava.android_apps'

//    version = project.catkin.pkg.version

    repositories {

        mavenCentral()

    }

}

subprojects {

    apply plugin: 'ros-android'

    afterEvaluate { project ->

        android {

            packagingOptions {

                /*https://github.com/rosjava/android_core/issues/194 */

                exclude 'META-INF/LICENSE.txt'

                exclude 'META-INF/NOTICE.txt'

            }

        }

    }

}

defaultTasks'assembleRelease', 'uploadArchives'

dependencies {

}

** teleop| build.gradle

dependencies {

  compile'com.android.support:appcompat-v7:23.3.0'

  compile'com.github.rosjava.android_remocons:common_tools:[0.2,0.3)'

  compile'org.ros.android_core:android_15:[0.2,0.3)'

}

apply plugin:'com.android.application'

android {

  compileSdkVersion 23

  buildToolsVersion "23.0.3"

  defaultConfig {

    minSdkVersion 15

    targetSdkVersion 23

    versionCode 2

    versionName "1.0.0"

  }

  productFlavors {

    indigo {

      applicationId"com.github.rosjava.android_apps.teleop.indigo"

      }

  }

}

** indigo-devel| gradle|wrapper| gradle-wrapper.properties

#Mon Jun 20 11:38:32 CST2016

distributionBase=GRADLE_USER_HOME

distributionPath=wrapper/dists

zipStoreBase=GRADLE_USER_HOME

zipStorePath=wrapper/dists

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

** settings| gradle

Use default gradel wrapper(recommended)

不选择Offlinework        ----------这个很重要,关系到能否连接到远程仓库,加入远程包。

** settings| projectstructure| teleop| properties: Compile Sdk version:  API 23: Android 6.0 (Mar...)

Build Tools Version:23.0.3

Flavors| Min Sdk Version:API 15: Android 4.0.3 (IceCreamSandwich)

      | Target Sdk Version: API 23: Android 6.0 (Marshmallow)

      Version Code: 2

      Version Name: 1.0.0

Dependencies:

  com.android.support:appcompat-v7:23.3.0

 com.github.rosjava.android_remocons:common_tools:[0.2,0.3)

  org.ros.android_core:android_15:[0.2,0.3)

** 经验:多看错误记录、日志,自己理解后解决,不用盲目google。

***********************************************

* app| build.gradle 完整的gradle脚本http://stormzhang.com/devtools/2015/01/15/android-studio-tutorial6/

apply plugin:'com.android.application'

def releaseTime() {

    return newDate().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))

}

android {

    compileSdkVersion 21

    buildToolsVersion '21.1.2'

    defaultConfig {

        applicationId "com.boohee.*"

        minSdkVersion 14

        targetSdkVersion 21

        versionCode 1

        versionName "1.0"

        // dex突破65535的限制

        multiDexEnabled true

        // 默认是umeng的渠道

        manifestPlaceholders =[UMENG_CHANNEL_VALUE: "umeng"]

    }

    lintOptions {

        abortOnError false

    }

    signingConfigs {

        debug {

            // No debug config

        }

        release {

            storeFilefile("../yourapp.keystore")

            storePassword "yourpassword"

            keyAlias "your alias"

            keyPassword "yourpassword"

        }

    }

    buildTypes {

        debug {

            // 显示Log

            buildConfigField"boolean", "LOG_DEBUG", "true"

            versionNameSuffix"-debug"

            minifyEnabled false

            zipAlignEnabled false

            shrinkResources false

            signingConfig signingConfigs.debug

        }

        release {

            // 不显示Log

            buildConfigField"boolean", "LOG_DEBUG", "false"

            minifyEnabled true

            zipAlignEnabled true

            // 移除无用的resource文件

            shrinkResources true

            proguardFilesgetDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            signingConfigsigningConfigs.release

            applicationVariants.all { variant->

                variant.outputs.each { output->

                    def outputFile =output.outputFile

                    if (outputFile != null&& outputFile.name.endsWith('.apk')) {

                    // 输出apk名称为boohee_v1.0_2015-01-15_wandoujia.apk

                        def fileName ="boohee_v${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk"

                        output.outputFile = newFile(outputFile.parent, fileName)

                    }

                }

            }

        }

    }

    // 友盟多渠道打包

    productFlavors {

        wandoujia {}

        _360 {}

        baidu {}

        xiaomi {}

        tencent {}

        taobao {}

        ...

    }

    productFlavors.all { flavor ->

        flavor.manifestPlaceholders =[UMENG_CHANNEL_VALUE: name]

    }

}

dependencies {

    compile fileTree(dir: 'libs', include:['*.jar'])

    compile'com.android.support:support-v4:21.0.3'

    compile 'com.jakewharton:butterknife:6.0.0'

    ...

}

***********************************************

* app| build.gradle

android {

    productFlavors { -------------多渠道打包,xiaomi{}是指打包xiaomi版本的,同步以后,命令gradlewbuild,生成的包的版本在app/build/outputs/apk下。

        dev {

            manifestPlaceholders = [channel:"dev"]

        }

        official {

            manifestPlaceholders = [channel:"official"]

        }

        xiaomi {

            manifestPlaceholders = [channel:"xiaomi"]

        }

        wandoujia {

            manifestPlaceholders = [channel:"wandoujia"]

        }

        "360" {

            manifestPlaceholders = [channel:"360"]

        }

    }

}

参考http://blog.csdn.net/chengkaizone/article/details/51365020#t4

***********************************************

* configurations语句

configurations { } https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#org.gradle.api.Project:configurations(groovy.lang.Closure)

Configures the dependencyconfigurations for this project.

This method executes thegiven closure against the ConfigurationContainer for this project. TheConfigurationContainer is passed to the closure as the closure's delegate.

Examples:

See docs forConfigurationContainer

Delegates to:

ConfigurationContainerfrom configurations

你可能感兴趣的:(android,Android,Studio安装配置)