我的项目中有以下模块:
MyProject
- app // the usual module that contains the java codes
- theLibraryModule // this is the module in question
- theLibraryDebug.aar
- theLibraryRelease.aar
- build.gradle
theLibraryModule
的build.gradle
在下面:configurations.maybeCreate("default")
artifacts.add("default", file('theLibraryDebug.aar'))
有没有办法检查我正在使用的构建变体(调试/发布)并在我的
theLibraryModule
中加载正确的 AAR模块?
最佳答案
检查此代码以检查 Gradle 中的构建变体。
// Customize your APK name here
applicationVariants.all { variant ->
variant.outputs.all { output ->
def appId = variant.applicationId// com.exampleFree.app OR com.examplePaid.app
def versionName = variant.versionName
def versionCode = variant.versionCode // e.g 1.0
def flavorName = variant.flavorName // e. g. Free
def buildType = variant.buildType.name // e. g. debug
def variantName = variant.name // e. g. FreeDebug
//customize your app name by using variables
outputFileName = "${buildType}.apk"
}
}
对于More
关于android - 如何检查模块的 build.gradle 中的构建变体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62071210/