0

I have a problem related to using urls from NDK. I want to use these depending on build variants, but I don't want to use this with runtime conditions like this

if (BuildConfig.BUILD_TYPE.equalsIgnoreCase("prod")) {
    //call native method getPROD_URL()
} else if (BuildConfig.BUILD_TYPE.equalsIgnoreCase("stage")) {
    //call native method getSTAGE_URL()
}

How can I connect ndk methods with gradle build types, like gradle.properties ?

Cryperian
  • 116
  • 1
  • 8
  • 1
    See https://stackoverflow.com/questions/44084950/set-android-mk-flag-through-gradle-depending-on-build-type/44108432#44108432 and https://stackoverflow.com/questions/46771588/read-build-arguments-from-ndk-code/46774983#46774983 – Michael Nov 06 '20 at 09:47
  • @Michael When I use CMake not ndkBuild then I can't fetch cFlags in native-lib.cpp. Do you have an experience related this case with CMake? – Cryperian Nov 09 '20 at 13:33
  • 1
    When using `ndkBuild`, `cFlags` are applied both when compiling C files and when compiling C++ files. When using `cmake` you may have to use `cppFlags` for flags that you want to be applied when compiling C++ files. – Michael Nov 09 '20 at 13:40

0 Answers0