Android Studio Gradle : how to configure buildTypes, 并在构建时检查哪种构建类型?

标签 android gradle android-studio

如何检查我的 build.gradle 中的 buildType 是否可调试?

我想做这样的事情:

if(debug) {
     file.write("xxxxx")
}

在我的 build.gradle 中

此外,如何从 AndroidStudio 构建调试和发布 buildType?我的意思不是通过键入 ./gradlew assembleReleaseassembleDebug 从命令行,我的意思是当您按下播放按钮时从 IDE 本身。这可能吗?

我在我的 android block 中配置了 buildTypes:

buildTypes {
    release {
        signingConfig signingConfigs.storeSign
        defaultConfig {
            versionCode 1100
            versionName "1.1.00"
        }
    }
    debug {
        defaultConfig {
            versionCode 1201
            versionName "1.2.01"
        }
    }
}

最佳答案

How can I check if a buildType is debuggable in my build.gradle?

您可以使用 buildType 的可调试标志来执行此操作。最终结果可能看起来像这样:

android {

    buildTypes.all { buildType ->
        println buildType.name
        print "Debuggable: "
        println buildType.debuggable
    }
}

Also, how can I build a debug and release buildType from AndroidStudio?

点击 Android Studio 左下角的“Build Variants”按钮打开 Build Variants 面板。您可以从那里选择要在运行/调试时使用的构建变体。

enter image description here

关于Android Studio Gradle : how to configure buildTypes, 并在构建时检查哪种构建类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21912199/

相关文章:

android - OpenGL ES 2.0 中从 GPU 到 GPU 的主要实现变化?

Android:高质量的Facebook个人资料图片

java - 运行 gradle 构建时出错

git - 在 Android Studio 导入期间维护目录结构

android - com.diffplug.gradle.spotless && 任务清理(类型 : Delete){} Error:Cannot add task 'clean' as a task with that name already exists

android - Phonegap 视频捕捉崩溃

android - 配置android以编程方式运行ffmpeg命令

android - list 合并失败

android-studio - Gradle同步失败,android-studio3.6.3无法解析配置 ‘:classpath’的所有工件

android - 删除 JCenter() 后使用 Android YouTube 视频播放器 'com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5' 时出现错误