<span style="font-size:18px;color:#ff0000;">实现了:apk签名,多渠道打包,jar包依赖,换资源。</span>
<span style="font-size:18px;">
</span>
<span style="font-size:18px;"> </span><pre name="code" class="java">buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    //单文件依赖,不能同时依赖单文件,有依赖文件夹
    // compile files('libs/android-support-v4.jar')
    //依赖文件夹下的  .jar
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 16
    }
//给apk签名
    signingConfigs {
        release {
            storeFile file("src/key.keystore")
            storePassword "123456"
            keyAlias "wang"
            keyPassword "123456"

        }
        buildTypes {
            release {

                signingConfig signingConfigs.release
            }
        }
    }

    //代码混淆
    buildTypes {
//            release {
//                debuggable false
//                jniDebugBuild true
//                signingConfig signingConfigs.myConfig
//            }
        release {
            runProguard true
            proguardFile getDefaultProguardFile('proguard-android.txt')
        }
    }
//;......
    tasks.withType(Compile) {
        options.encoding = "UTF-8"
    }
    //多渠道打包,有时候,带有中文注释会报错
    //Manifest中需要添加如下代码:
    //  <meta-data    android:name="channel"    android:value="${channelName}"/>
    productFlavors {
        yingyongbao {
            packageName "com.example.flavor1"
            versionCode 20
            manifestPlaceholders = [channelName: "YINGYONGBAO"]
        }
        umeng {

            manifestPlaceholders = [channelName: "UMENG"]
        }
        豌豆荚 {
            manifestPlaceholders = [channelName: "豌豆荚"]
        }

    }
    /**
     * 配置多渠道版本的信息
     */
    sourceSets {
        umeng {

            java.srcDirs = ['src/main/java', 'src/umeng/java']
            res.srcDirs = ['src/mainn/res', 'src/umeng/res']
            assets.srcDirs = ['src/main/assets', 'src/umeng/assets']
        }
    }

}