I have a React Native application and I'm trying to specify the folder for storing the generated source map in project.ext.react like so (I need it to implement a library which will help me debug JS errors)
project.ext.react = [
...
extraPackagerArgs : [ "--sourcemap-output", "$buildDir/intermediates/assets/$buildType/index.android.bundle.map" ]
]
As evident, the path should be something like <buildDir>/intermediates/assets/<buildType>/index.android.bundle.map
(e.g.
<buildDir>/intermediates/assets/release/index.android.bundle.map in case of release and <buildDir>/intermediates/assets/debug/index.android.bundle.map in case of debug)
After referring to several answers on StackOverflow and outside, I'm getting the buildType in the build.gradle by declaring it first and then assigning it:
//3rd line of build.gradle
def buildType
....
//much later
applicationVariants.all { variant ->
buildType = variant.buildType.name
....
However, this leads to a problem where buildType is initialized much after it is used, and so the output path becomes something like <buildDir>/intermediates/assets/null/index.android.bundle.map, thereby failing the whole process for me. Is there a way to get the build type earlier on?