just want to ask if how can I exclude a folder upon compiling a Release APK. I have this Resources folder filled with json files used for my simulations(Debug only) but would want to exclude this when compiling to a Release Apk.
Kindly see attached image Image.
You can use different assets folder, like:
app/src/main/assets
app/src/debug/assets
app/src/release/assets
Or you can define different src folders in the build.gradle file:
sourceSets {
main.java.srcDirs = ['...']
main.res.srcDirs = ['...']
main.assets.srcDirs = ['...']
debug.assets.srcDirs = ['...']
flavor1.assets.srcDirs = ['...']
}
To check the "debug" value you can use the default BuildConfig.DEBUG. In the same way you can define your own boolean value:
buildTypes {
debug {
buildConfigField "boolean", "MYVALUE", "true"
}
release {
buildConfigField "boolean", "MYVALUE", "false"
}
}
The automatically-generated BuildConfig class will contain the following fields based on the directive above:
public class BuildConfig {
// ... other generated fields ...
public static final boolean MYVALUE = false;
}