我在下面设置了gradle配置。允许并排安装不同的构建/风格
buildTypes {
release {
}
debug {
applicationIdSuffix ".debug"
// Somehow add debug suffix to app ID?
}
}
productFlavors {
ci {
applicationId "com.myapp.ci"
ext.betaDistributionGroupAliases = "mobileworkforce.ci"
resValue "string", "app_name", "AppName.CI"
}
staging {
applicationId "com.myapp.staging"
resValue "string", "app_name", "AppName.Staging"
}
production {
applicationId "com.myapp"
resValue "string", "app_name", "AppName"
}
问题在于我无法弄清楚如何更新app_name
字符串资源以获得后缀" Debug"到app_name字符串资源(用作应用程序的标签)
答案 0 :(得分:0)
我能够使用manifestPlaceholders创建一个可行的解决方案,而不是生成字符串资源。这不是理想的,因为结果是AppName.CI.Debug
而不是buildTypes {
release {
manifestPlaceholders = [ activityLabel:"AppName"]
}
debug {
applicationIdSuffix ".debug"
manifestPlaceholders = [ activityLabel:"AppName.Debug"]
}
}
productFlavors {
def addActivityLabelSuffix = { placeholders, suffix ->
def appName = placeholders.get("activityLabel")
placeholders.put("activityLabel", appName + suffix);
}
ci {
applicationId "com.myapp.ci"
ext.betaDistributionGroupAliases = "mobileworkforce.ci"
addActivityLabelSuffix getManifestPlaceholders(), ".CI"
}
staging {
applicationId "com.myapp.staging"
addActivityLabelSuffix getManifestPlaceholders(), ".Staging"
}
production {
applicationId "com.myapp"
resValue "string", "app_name", "AppName"
}
}
,但它有效。
$query = "INSERT INTO mytable (Title,Author)
VALUES('".sql_safe($Title)."', '"sql_safe($Author)."'); SELECT Scope_Identity() as myid;";
$result = odbc_exec($con1, $query);
答案 1 :(得分:0)
使用 getManifestPlaceholders().get("...")
我总是得到空值,所以我正在寻找另一个解决方案......也许更好,因为我可以在应用程序名称中获得正确的顺序......
// build.gradle
def appNameBase = "My App"
buildTypes {
release {
manifestPlaceholders = [ appNameBase: appNameBase, appNameSuffix: "" ]
}
debug {
manifestPlaceholders = [ appNameBase: appNameBase, appNameSuffix: " Debug" ]
applicationIdSuffix ".debug"
}
}
productFlavors {
one {
manifestPlaceholders = [ appNameFlavor: "One" ]
}
two {
manifestPlaceholders = [ appNameFlavor: "Two" ]
}
}
// AndroidManifest.xml
<application android:label="${appNameBase} ${appNameFlavor}${appNameSuffix}" ...>
在我的情况下,我想要的只是“我的应用程序一”和“我的应用程序二”广告用于调试“我的应用程序一调试”和“我的应用程序二调试”,上面的代码效果很好。