直接看code
module app build.gradle
apply plugin: 'com.android.application'android {compileSdkVersion 28defaultConfig {applicationId "com.example.wlh.androidencrypt"minSdkVersion 23targetSdkVersion 28versionCode 1versionName "1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"flavorDimensions "versionCode" //多渠道打包 必须加,不然 报错 All flavors must now belong to a named flavor dimension.}buildTypes {release {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'buildConfigField("boolean", "enableLog", "true") // for java BuildConfig.enableLog 控制log}debug {ext.enableCrashlytics = falseext.alwaysUpdateBuildId = falsebuildConfigField("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 truepreDexLibraries truemaxProcessCount 8}//关闭不需要tasktasks.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:+HeapDumpOnOutOfMemoryError
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.configureondemand=true
github ok地址:
https://github.com/wanlihua2006/MultiMarket_opt