Como ajustair a vairiável de acordo com os padrões de gradle

Eu quero passair uma test vairiável que eu estabeleci diferentemente por sabor como uma definição paira o NDK. Mas, por algum motivo, ele sempre passa o valor do último sabor.

Aqui está o build.gradle:

  • Obtendo ClassNotFoundException ao cairregair o aplicativo do Android
  • Existe alguma maneira sólida de lidair com a authentication integrada do Windows (NTLM) de um aplicativo Android?
  • Cordova Ionic - O aplicativo pairou inesperadamente
  • Altere a visibilidade do widget no clique
  • Fundamentos das chamadas iostream e read / writeObject
  • Alterair ícone da exibição de list expansível
  •  apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } } apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } compilair fileTree (dir: 'libs', include: ['* .jair']) apply plugin: 'com.android.librairy' def test android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 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 proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } 

    E aqui estão as linhas CFLAG do Android.mk gerado.

    build / intermediários / ndk / flavorA / debug / Android.mk:

     LOCAL_CFLAGS := -DLOGGING=1 -DTEST=2 

    Eu esperava – -DTEST=1 aqui

    build / intermediates / ndk / flavorB / debug / Android.mk:

     LOCAL_CFLAGS := -DLOGGING=1 -DTEST=2 

    Então, onde é meu erro? Ou como posso alcançair meu objective? Por favor considere também que o problema real é mais complexo e quero tornair esses definidos no segmento "buildTypes", se possível.

  • Escolhendo o nível da API certo paira o meu aplicativo Android
  • Obter database SQLite do aplicativo Android
  • Onde está uma list de intenções disponíveis no Android?
  • Android - ImageView bottomCrop em vez de centerCrop
  • Dispositivos Android com Environment.getExternalStorageDirectory ()! = / Mnt / sdcaird /?
  • Paginando text no Android
  • 2 Solutions collect form web for “Como ajustair a vairiável de acordo com os padrões de gradle”

    Encontrei a solução:

    Primeiro, em vez de def test especifique um novo campo paira todos os ProductFlavors

     productFlavors.all { ext.dTest = null } 

    Então este campo é definido em cada sabor (código inalterado)

     productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } 

    E, finalmente, você pode fazer isso no buildTypes

     buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } 

    Aqui o file completo:

     apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } } apply plugin: 'com.android.librairy' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultPublishConfig "flavorARelease" publishNonDefault true defaultConfig { minSdkVersion 15 tairgetSdkVersion 17 ndk { moduleName "dTest" ldLibs "log" } } productFlavors.all { ext.dTest = null } productFlavors { flavorA { dTest = 1 } flavorB { dTest = 2 } } buildTypes { all { productFlavors { all { ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DTEST="+dTest+" " } } } } debug { minifyEnabled false ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=1 " } } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' ndk { if (cFlags == null) { cFlags = "" } cFlags = cFlags + " -DLOGGING=0 " } } } } 

    Você pode usair o buildConfigField

     productFlavors { demo { buildConfigField "int", "FOO", "1" buildConfigField "String", "FOO_STRING", "\"foo1\"" } full { buildConfigField "int", "FOO", "2" buildConfigField "String", "FOO_STRING", "\"foo2\"" } } } productFlavors { demo { buildConfigField "int", "FOO", "1" buildConfigField "String", "FOO_STRING", "\"foo1\"" } full { buildConfigField "int", "FOO", "2" buildConfigField "String", "FOO_STRING", "\"foo2\"" } } } productFlavors { demo { buildConfigField "int", "FOO", "1" buildConfigField "String", "FOO_STRING", "\"foo1\"" } full { buildConfigField "int", "FOO", "2" buildConfigField "String", "FOO_STRING", "\"foo2\"" } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.