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

* 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

更多相关文章

  1. NPM 和webpack 的基础使用
  2. Android(安卓)系统应用调用,intent 的使用方法总结
  3. 什么是Android?
  4. Android(安卓)Http基础:图片下载并显示和WebView的应用
  5. androidの常用基础应用知识总结
  6. android中跳转系统自带界面
  7. Protect Broadcast 保护广播
  8. Android:apk反编译步骤,打包、签名和逆向工程经验总结
  9. 【API Guides视频系列】第1篇Application Fundamentals(应用程序

随机推荐

  1. ArcGis Android(安卓)10.2.6更新文档翻译
  2. Android(安卓)存储选项之 SQLite 优化那
  3. Android面试系列文章2018之Android部分Fr
  4. android设置透明背景
  5. android:ellipsize的使用
  6. Hello, Android(安卓)深入(一)
  7. Android(安卓)入门前言之 --布局
  8. Android(安卓)之不要滥用 SharedPreferen
  9. Android架构组件- Room数据库的使用
  10. Android开发教程