android library增加productFlavors,并在app module 引用某个flavors

library中增加productFlavors和appmodule中类似

productFlavors{
    buildConfigField "boolean", "ReadTestServer", "false"
    sdkDemoTest{
        buildConfigField "boolean", "ReadTestServer", "true"
        buildConfigField "boolean", "SDKDemo", "true"
    }
    sdkDemoOfficial{
        buildConfigField "boolean", "SDKDemo", "true"
    }
}

这时如果app module中按照正常的 

compile project(':app') 会发现无法引用到项目,编译会发现library中的所有类都无法找到

需要使用如下方式指定使用的flavors进行引用:

compile project(path: ':app',configuration:'sdkDemoOfficialDebug')
compile project(path: ':app',configuration:'sdkDemoOfficialRelease')


你可能感兴趣的:(小事杂谈,编译相关)