After a few tries I found this blog post, the configuration it suggests did not work on my project, however it had insights about the location of node_modules (it is a couple of folders above what it "should be", i.e. an extra ../../) .
After some modifications I got it working:
packages/<package_name>/android/settings.gradle - add extra ../../:
pluginManagement { includeBuild("../../../node_modules/@react-native/gradle-plugin") }
...
includeBuild('../../../node_modules/@react-native/gradle-plugin')
packages/<package_name>/android/app/build.gradle - modify the default locations and add extra ../../:
...
reactNativeDir = file("../../../../node_modules/react-native")
...
codegenDir = file("../../../../node_modules/@react-native/codegen")
...