productFlavors 差异打包问题

差异化打包:
1。dependencies compile 是不可以放到差异化的productFlavors里面的。
会报错:

Error:(69, 0) Could not find method compile() for arguments [{name=meitu-openaccount-1.0.0-release, ext=aar}] on ProductFlavor_Decorated{

name=meitu, dimension=null, minSdkVersion=null, targetSdkVersion=null, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=com.chaozh.ireadermeitu, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={CHANNEL_ID=com.android.builder.internal.ClassFieldImpl@af6be09a}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.ProductFlavor.

所有可以在productFlavors里面配置的,就都在这里面了。

错:是可以的。参考:
https://www.2cto.com/kf/201701/589923.html
shandongCompile files(“libs/mtclib_170110_sd.jar”)
beijingCompile files(“libs/mtclib_170110_sd.jar”)

2。资源合并的时候,如果说,你的图片只在xxh-dpi里面有,那么可能,程序跑起来,他可能不根据你差异化里面的图片去匹配。去根据主工程去匹配。

3.assemble结合Build Variants来创建task

总之,assemble 命令创建task有如下用法:
assemble: 允许直接构建一个Variant版本,例如assembleFlavor1Debug。
assemble: 允许构建指定Build Type的所有APK,例如assembleDebug将会构建Flavor1Debug和Flavor2Debug两个Variant版本。
assemble: 允许构建指定flavor的所有APK,例如assembleFlavor1将会构建Flavor1Debug和Flavor1Release两个Variant版本。

资源:
1。productFlavors dsl大全
http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.ProductFlavor.html

原文地址:https://www.cnblogs.com/caoxinyu/p/10568585.html