多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
https://blog.csdn.net/and_you_with_me/article/details/78799226 ## 举例 ~~~ apply plugin: 'com.android.application' // 当前beta版本号 ext.build_number = "beta1"; // 显示的时间格式,形如20171110 def releaseTime() { return new Date().format("yyyyMMdd", TimeZone.getDefault()); } android { useLibrary 'org.apache.http.legacy' compileSdkVersion 25 buildToolsVersion "27.0.3" defaultConfig { applicationId "com.jinnong" minSdkVersion 14 targetSdkVersion 25 versionCode 6 versionName "1.0.6" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true } applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.apk')) { // 显示app名称+当前版本号 def fileName = "TouchH-V${variant.versionName}" // 如果有渠道,显示渠道名"" if (variant.flavorName!=""){ fileName = fileName + "-${variant.flavorName}" } // 加入打包时间 fileName = fileName + "-${releaseTime()}" // 如果是debug版本,加入beta版本号 if ('debug'.equals(variant.buildType.name)) { fileName = fileName + "-${build_number}.apk" } else { // 如果是release版本,直接显示 fileName = fileName + "-release.apk" } output.outputFile = new File(outputFile.parent, fileName) } } } signingConfigs { release { keyAlias 'jnkey' keyPassword '123456' storeFile file('C:/Users/Administrator/Desktop/jnkey.jks') storePassword '123456' } } buildTypes { release { //Zipalign优化 zipAlignEnabled true // 移除无用的resource文件 shrinkResources false minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } } sourceSets { main { jniLibs.srcDirs = ['libs'] } } splits { abi { enable true reset() include 'armeabi-v7a' } } packagingOptions { exclude 'META-INF/rxjava.properties' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/notice.txt' exclude 'META-INF/license.txt' exclude 'META-INF/dependencies.txt' exclude 'META-INF/LGPL2.1' exclude 'META-INF/maven.com.squareup.retrofit2.converter-gson/pom.xml' } repositories { flatDir { dirs 'libs' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:design:25.3.1' compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' //compile files('libs/BaiduLBS_Android.jar') compile files('libs/gson-2.2.4.jar') compile files('libs/universal-image-loader-1.9.5.jar') compile 'com.jakewharton:butterknife:7.0.1' compile 'com.wang.avi:library:2.1.3' compile 'org.apache.httpcomponents:httpcore:4.4.2' compile(name: 'AliyunPlayer', ext: 'aar') compile 'com.android.support:multidex:1.0.1' compile 'com.tencent.bugly:crashreport:latest.release' } ~~~