In my React Native project, I need to set a few things like minSdkVersion, targetSdkVersion, etc. In the build.gradle file, I see references to rootProject.ext section which appears to be a central location for settings. I ran a search in the project but couldn't find rootProject.ext anywhere except in this section of build.gradle. I can "cheat" and put actual values in there and it works but I'd like to know where rootProject.ext is. For example, where's the compileSdkVersion or minSdkVersion coming from in the following code?
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.ingridtm"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
}
P.S. This is out of a regular React Native project -- targeting 0.63.4 -- that is created with npx react-native init myproject. So I changed nothing in build.gradle up to this point.
You can place these root settings in your project-level build.gradle file (at android/build.gradle), in the buildscript section:
buildscript {
ext {
buildToolsVersion = "29.0.2"
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With