【发布时间】:2013-06-28 11:30:04
【问题描述】:
我想知道如何创建不同的构建配置,使用 Android Studio 为调试和发布构建提供不同的常量(例如,服务器地址、API 密钥……)。
【问题讨论】:
-
这看起来不像是指定问题的重复。
标签: android configuration android-studio
我想知道如何创建不同的构建配置,使用 Android Studio 为调试和发布构建提供不同的常量(例如,服务器地址、API 密钥……)。
【问题讨论】:
标签: android configuration android-studio
编辑模块中的build.gradle 文件并将以下任何内容添加到您的android{} 容器中。
signingConfigs {
release {
storeFile file("path relative to the root of the project")
storePassword "PASSWORD!"
keyAlias "projectname"
keyPassword "PASSWORD!"
}
}
buildTypes {
debug {
versionNameSuffix "-DEBUG"
packageNameSuffix ".debug"
}
release {
debuggable false
signingConfig signingConfigs.release
}
debugRelease.initWith(buildTypes.release)
debugRelease {
debuggable true
packageNameSuffix '.debugrelease'
signingConfig signingConfigs.release
}
}
}
这增加了 3 种构建类型(release、debugRelease 和 debug)
release 和 debugRelease 使用相同的键,并且 debugRelease 是 Release 的副本。
【讨论】: