android studio3 多渠道打包及编译速度优化等
16lz
2021-01-23
直接看code
module app build.gradle
apply plugin: 'com.android.application'android { compileSdkVersion 28 defaultConfig { applicationId "com.example.wlh.androidencrypt" minSdkVersion 23 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" flavorDimensions "versionCode" //多渠道打包 必须加,不然 报错 All flavors must now belong to a named flavor dimension. } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' buildConfigField("boolean", "enableLog", "true") // for java BuildConfig.enableLog 控制log } debug { ext.enableCrashlytics = false ext.alwaysUpdateBuildId = false buildConfigField("boolean", "enableLog", "true") applicationIdSuffix ".debug" versionNameSuffix "-debug" } } //多渠道打包 productFlavors{ googleplay{} dev { manifestPlaceholders = [channel: "dev"] resConfigs "en","xxhdpi" } official { manifestPlaceholders = [channel: "official"] resConfigs "en","xxhdpi" } wandoujia { manifestPlaceholders = [channel: "wandoujia"] resConfigs "en","xxhdpi" } xiaomi { manifestPlaceholders = [channel: "xiaomi"] resConfigs "en","xxhdpi" } "360" { manifestPlaceholders = [channel: "360"] resConfigs "en","xxhdpi" } tencent { manifestPlaceholders = [UMENG_CHANNEL: "Tencent"] //resConfigs "en","xxhdpi" } } //自动输出自定义名字// applicationVariants.all { variant ->// variant.outputs.each { output ->// output.outputFile = new File(// output.outputFile.parent + "/${variant.buildType.name}","lihua-${variant.buildType.name}-${variant.versionName}-${variant.productFlavors[0].name}.apk".toLowerCase())// }// } applicationVariants.all { variant -> variant.outputs.all { output -> outputFileName = "AndroidEncrypt_${variant.productFlavors[0].name}_${variant.buildType.name}_v${variant.versionName}.apk" } } //禁止png crunching, 禁止构建时默认压缩图片的方法 aaptOptions { cruncherEnabled false } // dex预处理和最多八线程 dexOptions{ // incremental true preDexLibraries true maxProcessCount 8 } //关闭不需要task tasks.whenTaskAdded { task -> if(task.name.contains("lint") || task.name.contains("Aidl") || task.name.contains("mockableAndroidJar") || task.name.contains("UnintTest") || task.name.contains("AndroidTest") || task.name.contains("Ndk") || task.name.contains("Jni") ){ task.enabled = false } }}dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'}
gradle.properties
org.gradle.jvmargs=-Xmx1536m -XX:+HeapDumpOnOutOfMemoryErrororg.gradle.parallel=trueorg.gradle.daemon=trueorg.gradle.configureondemand=true
github ok地址:
https://github.com/wanlihua2006/MultiMarket_opt
更多相关文章
- android 图片处理
- android 安卓 开发 图片库获得图片的绝对路径
- TableRow 背景问题以及修改对话框标题高度或者图片
- Android 把从网络获取的图片缓存到内存中
- 浅析Android线程模型一 --- 转
- android中线程的应用
- Android 的网络编程(17)-android显示网络图片
- Android进程与线程基本知识
- 浅析Android单线程模型