android gradle 配置 build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
    	classpath 'com.android.tools.build:gradle:0.9.0+'
    }
}
apply plugin: 'android'

repositories {
  mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    //引用别的项目
    compile project(':*')
}
tasks.withType(Compile) {
	options.encoding = "UTF-8"
}
android {
    compileSdkVersion 17
    buildToolsVersion "19.0.3"
    packagingOptions {
		exclude 'META-INF/NOTICE.txt'
		exclude 'META-INF/LICENSE.txt'
  	}
  	lintOptions {
    	abortOnError false
	}
    signingConfigs {
        myConfig {
            storeFile file("*")
            storePassword "*"
            keyAlias "*"
            keyPassword "*"
        }
    }
    
    defaultConfig {
        versionCode getVersionCode()
        versionName getVersionName()
        minSdkVersion 8
        targetSdkVersion 15
    }
    
    productFlavors {
        hiapk{
        }
        _91sj{
        }
        appchina{
        }
        google{
        }
        _360cn{
        }
        _3gcn{
        }
        meizu{
        }
        qq{
        }
        wandoujia{
        }
        xiaomi{
        }
        baidu{
        }
        goapk{
        }
        nduoa{
        }
        gfan{
        }
    }
    
    buildTypes{
        release {
            signingConfig signingConfigs.myConfig
            runProguard true
            proguardFile 'proguard.cfg'
        }
    }
	
    sourceSets {
        main {
            manifest {
                srcFile 'AndroidManifest.xml'
            }
            java {
                srcDir 'src'
            }
            res {
                srcDir 'res'
            }
            assets {
                srcDir 'assets'
            }
            resources {
                srcDir 'src'
            }
            aidl {
                srcDir 'src'
            }
            jniLibs{
            	srcDir 'libs'
            }
        }
    }
}

android.applicationVariants.all{ variant -> 
    variant.processManifest.doLast{
        copy{
            from("${buildDir}/manifests"){
                include "${variant.dirName}/AndroidManifest.xml"
            }
            into("${buildDir}/manifests/$variant.name")

            filter{
                //
                String line -> line.replaceAll("UMENG_CHANNEL_VALUE", ("${variant.productFlavors[0].name}"-'_'))
            }

            variant.processResources.manifestFile = file("${buildDir}/manifests/${variant.name}/${variant.dirName}/AndroidManifest.xml")
        }    
   }
}

你可能感兴趣的:(android,gradle,配置)