android - 如何检查模块的 build.gradle 中的构建变体

标签 android gradle

我的项目中有以下模块:

MyProject
 - app  // the usual module that contains the java codes
 - theLibraryModule  // this is the module in question
   - theLibraryDebug.aar
   - theLibraryRelease.aar
   - build.gradle
theLibraryModulebuild.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/

相关文章:

android - 无法解析 Twitter SDK

android - 有没有一种简单的方法可以在 Android View 的顶部和底部添加边框?

xml - Android 布局文件中的所有小部件都需要 layout_width 和 layout_height 吗?

android - 谷歌地图上的当前位置没有打开 GPS(android 设备)?

android - Flutter .apk 已构建但未安装在设备/模拟器中

android - Gradle不下载链接到 Artifact 的依赖项

android - 如何获取android webView中的触摸事件信息?

Android NDK 应用程序库未找到错误

Android Gradle 模块依赖

java - Heroku 部署失败,Java Dropwizard 项目使用 Gradle