包含带有风味android的库

包含带有风味android的库,第1张

概述我的应用程式gradle档案之前:编译项目(路径:’:zblelib’)但是,当我在库中添加口味时,我的导入无法正常工作我的口味:flavorDimensions"dim"productFlavors{nocustomer{versionNameSuffix"-nocustomer"dimension="dim"}

我的应用程式gradle档案之前:

编译项目(路径:’:zblelib’)

但是,当我在库中添加口味时,我的导入无法正常工作

我的口味:

flavorDimensions "dim"    productFlavors {        nocustomer {            versionnameSuffix "-nocustomer"            dimension = "dim"        }        customer001 {            versionnameSuffix "-customer001"            dimension = "dim"        }    }

如何选择口味导入新库?

编辑:我的build.gradle

图书馆

androID {    compileSdkVersion 27    buildToolsversion '27.0.3'    defaultConfig {        minSdkVersion 18        targetSdkVersion 26    }    buildTypes {        deBUG {            MinifyEnabled false            proguardfiles getDefaultProguardfile('proguard-androID-optimize.txt'), 'proguard-rules.pro'        }        release {            MinifyEnabled true            proguardfiles getDefaultProguardfile('proguard-androID-optimize.txt'), 'proguard-rules.pro'        }    }    flavorDimensions "dim"    productFlavors {        nocustomer {            versionnameSuffix "-nocustomer"            dimension = "dim"        }        customer001 {            versionnameSuffix "-customer001"            dimension = "dim"        }    }}dependencIEs {    compile filetree(include: ['*.jar'], dir: 'libs')    testCompile 'junit:junit:4.12'    compile 'com.androID.support:appcompat-v7:27.1.1'    compile 'com.androID.support:design:27.1.1'    compile 'com.androID.support:support-v4:27.1.1'    compile project(':criptolib-deBUG')}

应用程式

androID {    compileSdkVersion 27    buildToolsversion '27.0.3'    defaultPublishConfig "nocustomerRelease"    defaultConfig {        applicationID "com.axesstmc.bleappphone"        minSdkVersion 18        targetSdkVersion 26        versionCode 91        versionname "8.2"    }    buildTypes {        deBUG {            MinifyEnabled false            //proguardfiles 'proguard-rules.pro'        }        release {            MinifyEnabled true            shrinkResources true            proguardfiles getDefaultProguardfile('proguard-androID-optimize.txt'), 'proguard-rules.pro'        }    }}dependencIEs {    ? ?}

解决方法:

应用程序存在的问题是它不知道要使用哪个库的样式.

关键字matchingFallbacks将告诉应用程序您要选择哪种库的样式.但是此关键字必须与Flavor一起使用.

我们必须在您的应用程序build.gradle上添加一个风味(尺寸):

androID {    ...    //flavorDimensions is mandatory with flavors. Use the same name on your 2 files to avoID other conflicts.    flavorDimensions "dim"    productFlavors {        nocustomer{            dimension "dim"            // App and library's flavor have the same name.            // MatchingFallbacks can be omitted            matchingFallbacks = ["nocustomer"]        }        customerNb{            dimension "dim"            // Here the app and library's flavor are different            // Matching fallbacks will select the library's flavor 'customer001'            matchingFallbacks = ["customer001"]        }    }    ...}dependencIEs {    implementation project(':zblelib')}

这样,当您选择应用程序的样式nocustomer时,库的样式将自动选择nocustomer,而当您选择应用程序的样式客户customerNb时,库的样式将自动选择customer001

聚苯乙烯

我使用实现而不是编译,因为不建议使用编译(see here)

总结

以上是内存溢出为你收集整理的包含带有风味android的库全部内容,希望文章能够帮你解决包含带有风味android的库所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1092106.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存