gpt4 book ai didi

android - 如何为发布/调试版本提供不同的 gradle.properties 文件?

转载 作者:行者123 更新时间:2023-12-03 04:46:15 34 4
gpt4 key购买 nike

我们需要有 gradle.properties发布和调试版本具有不同配置的文件,因为我们使用的一些功能是实验性的,它们会破坏一些东西。那可能吗?

我们的示例 gradle.properties文件

org.gradle.daemon=true
org.gradle.jvmargs=-Xmx1500m -XX:MaxPermSize=512m
org.gradle.parallel=true
kotlin.incremental=true
android.enableD8=true

最佳答案

根据官方文档:

您可以在 android block 内的模块级 build.gradle 文件中创建和配置构建类型。当您创建新模块时,Android Studio 会自动为您创建调试和发布构建类型。虽然调试构建类型没有出现在构建配置文件中,但 Android Studio 将其配置为 debuggable true。这允许您在安全的 Android 设备上调试应用程序,并使用通用调试 keystore 配置 APK 签名。

如果要添加或更改某些设置,可以将调试构建类型添加到配置中。以下示例为调试构建类型指定 applicationIdSuffix,并配置使用调试构建类型中的设置初始化的“暂存”构建类型。

您可以将相同的 build.gradle 用于发布和 Debug模式,例如:

buildTypes {
release {
// Do whatever you want to do in release mode
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

debug {
// Do whatever you want to do in debug mode
applicationIdSuffix ".debug"
debuggable true
}

/**
* The `initWith` property allows you to copy configurations from other build types,
* then configure just the settings you want to change. This one copies the debug build
* type, and then changes the manifest placeholder and application ID.
*/
staging {
initWith debug
manifestPlaceholders = [hostName:"internal.example.com"]
applicationIdSuffix ".debugStaging"
}
}

引用: Source

关于android - 如何为发布/调试版本提供不同的 gradle.properties 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47281907/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com