If 'android.defaults.buildfeatures.buildconfig = true' is not enough, then perhaps the menu will help: Build -> Rebuild Project.
A 'java (genereted)' folder containing the 'BuildConfig' class should then be created in the project navigator.
Build -> Rebuild must be called separately for each build (release, debug, ...) so that the class is created.