- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我想将一个变量 test
传递给 NDK。但由于某种原因,他总是通过最后一种味道的值(value)。
这是 build.gradle:
apply plugin: 'com.android.library'
def test
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultPublishConfig "flavorARelease"
publishNonDefault true
defaultConfig {
minSdkVersion 15
targetSdkVersion 17
ndk {
moduleName "test"
ldLibs "log"
}
}
productFlavors {
flavorA {
test = 1
}
flavorB {
test = 2
}
}
buildTypes {
debug {
ndk {
if (cFlags == null) { cFlags = "" }
cFlags = cFlags + " -DLOGGING=1 -DTEST="+test+" "
}
minifyEnabled false
}
release {
ndk {
if (cFlags == null) { cFlags = "" }
cFlags = cFlags + " -DLOGGING=0 -DTEST="+test+" "
}
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
这里是生成的 Android.mk 中的 CFLAG 行
构建/中间体/ndk/flavorA/debug/Android.mk:
LOCAL_CFLAGS := -DLOGGING=1 -DTEST=2
我期望 -DTEST=1
在这里
build/intermediates/ndk/flavorB/debug/Android.mk:
LOCAL_CFLAGS := -DLOGGING=1 -DTEST=2
那么我的错误在哪里?或者我怎样才能实现我的目标?另请考虑真正的问题更复杂,如果可能,我想在“buildTypes”部分中进行这些定义。
最佳答案
你可以使用 buildConfigField
productFlavors {
demo {
buildConfigField "int", "FOO", "1"
buildConfigField "String", "FOO_STRING", "\"foo1\""
}
full {
buildConfigField "int", "FOO", "2"
buildConfigField "String", "FOO_STRING", "\"foo2\""
}
}
关于android - 如何根据gradle flavor 设置变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36037041/
因此,从标题中可以看出,我有重复的问题。 您不允许在自己的口味和主目录中定义相同的文件。但是您可以使用xml资源执行此操作。 那么它是如何工作的呢?例如,我的构建变体是 RedStagingDebug
我正在使用 Android Studio(v 2.1,gradle 插件 v 2.1.0)开发一个 Android 应用程序。我的应用程序有多个版本,它们共享很多通用代码,因此我决定使用 flavor
productFlavors { India { } USA { } } 以2种产品口味为例 1。印度2.美国 构建变体的总数将
有没有一种方法可以结合构建类型和风格来获取构建变体,以便从最特定的res文件夹中获取资源? 可以说我有src/mainsrc/debugsrc/flavor1src/flavor2 在我的src/ma
我无法让产品口味发挥作用。我想要实现味道里面的味道例如,我有 2 个应用程序,我是这样声明的, productFlavors { abc { applicat
我收到类似 Error: Flavor 'fdroid' has no flavor dimension 这样的错误。将项目导入 Android Studio 后,请帮助我我在这里没有改变任何东西,它
一种 flavor 是否可能基于另一种 flavor ? 例如build.gradle: productFlavors { flavor1 { flavorBase "main
我有 Android Studio 1.3.1。当我打开旧项目时,Grandle 1.0.0 版本较低,升级它,更改 flavorGroups => flavorDimensions,packageN
在我当前的应用程序中,我有 2 个构建,我们称它们为 build 1 和 build 2。我知道两种风格可以共享公共(public)代码/资源,但也可以有单独的代码和资源,如下所示: 我想做的是扩展
我的母语不是英语,所以我不太了解“ flavor ”的含义可能是它指的是正则表达式语法??如果有的话,有多少正则表达式语法? BRE ERE Perl 等?? 最佳答案 正则表达式引擎实现的功能、它“
因此,我已经从事了一段时间的白色标签样式项目,并且在扩展性方面遇到了一些问题。具体来说,根据项目的工作方式,我需要能够基于每个客户端支持多个后端环境,每个后端环境都具有唯一的凭据。 我已经使用两种口味
我们正在尝试开发 2 种 gradle 口味以加快我们的开发过程: 将我们的库编译为模块的本地风格 使用我们库的最新快照的远程版本 我在 gradle 中声明了两种口味: productFlavors
我的应用程序级 build.gradle 文件中有以下内容: flavorDimensions "store", "features" productFlavors { amazon {
我有一个 Android 应用程序,有两种版本,免费版和收费版。我想创建另一种 flavor flavorExt,它基于免费 flavor 但具有一些附加功能。我已经使用 gradle 中的 sour
我在使用源代码集时遇到了一些麻烦,我有一个包含大部分常用代码的主要源代码集,但是之前的开发人员包含了一个构建风格开关,例如: if (Application.inKiosk) {
这个问题在这里已经有了答案: Android Flavors : Multiple java and src directories for each flavor (2 个答案) 关闭 7 年前。
任何人都可以向我解释如何将我的每种风格用于主要和特定于风格的 java/src 目录吗?我的目标是让目录被不止一种口味使用,但不是全部。 例如我有 3 种口味:A1、A2 和 B。 所有 favor
我的源代码树: app/src/main/java/com/example/A.java app/src/main/java/com/example/B.java 我想使用 productFlavor
我的应用程序包含 A 和 B 两种版本。当我运行 ./gradlew app:test 时,所有版本 A 的测试都通过,而版本 B 失败。我还有两种构建类型 debug 和 release。 我的架构
我知道我可以在 GitHub Flavored Markdown 中使用“代码”来突出显示代码片段。但我无法显示片段的行号。有没有办法做到这一点? ```javascript var s = "Jav
我是一名优秀的程序员,十分优秀!