经验

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
    }
}
apply plugin: 'com.android.application'



dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
    compile files('libs/alipaySdk-20160809.jar')
    compile project(':libzxing')
    compile 'io.reactivex:rxjava:1.0.14'
    compile 'io.reactivex:rxandroid:1.0.1'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile files('libs/libammsdk.jar')
    compile files('libs/SocialSDK_WeiXin_Full.jar')
    compile files('libs/umeng_social_api.jar')
    compile files('libs/umeng_social_net.jar')
}

//获取时间戳
def getDate() {
    def date = new Date()
    def formattedDate = date.format('yyyyMMdd_HHmm')
    return formattedDate
}
//从androidManifest.xml中获取版本号
//def getVersionNameFromManifest(){
//    def manifestParser = new com.android.builder.core.DefaultManifestParser()
//    return manifestParser.getVersionName(android.sourceSets.main.manifest.srcFile)
//}

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }

    defaultConfig {//默认配置
        multiDexEnabled true
        applicationId "com.cslo.tczs"//应用程序的包名
        minSdkVersion 9//支持的最低版本
        targetSdkVersion 19//支持的目标版本
        versionCode 1//版本号
        versionName "1.0.0"//版本名
//        manifestPlaceholders = [ UMENG_CHANNEL_VALUE:"hsq" ]//声明友盟渠道名是可变的
    }
    android{

        useLibrary 'org.apache.http.legacy'

    }



    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    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
            //Zipalign优化
            zipAlignEnabled true

            // 移除无用的resource文件
            shrinkResources true
            //前一部分代表系统默认的android程序的混淆文件,该文件已经包含了基本的混淆声明
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'

        }
    }

    //修改生成的apk名字
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def oldFile = output.outputFile
            def newName = '';
            if (variant.buildType.name.equals('release')) {
//                println(variant.productFlavors[0].name)
                def releaseApkName = 'lottery_3.3.4.3_android_' + getDate() + '_sit_' + defaultConfig.versionName + '.apk'
                output.outputFile = new File(oldFile.parent, releaseApkName)
            }
            if (variant.buildType.name.equals('beta')) {
                newName = oldFile.name.replace(".apk", "-v" + defaultConfig.versionName + "-build" + getDate() + ".apk")
                output.outputFile = new File(oldFile.parent, newName)
            }
            if (variant.buildType.name.equals('debug')) {

            }
        }
    }
}
















apply plugin: 'com.android.library'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile files('libs/zxing.jar')
}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值