`buildConfigField` seems to bug gradle parser causing flavor to not be detected
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 236
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 91
Description
### Build/Submit details page URL
_No response_
### Summary
I've been having [this issue](https://github.com/expo/eas-cli/issues/2133) after trying to get flavors to work in our bare project. Nothing made sense since I was just doing normal gradle stuff AND following [the docs](https://docs.expo.dev/build-reference/variants/#in-bare-project), so I decided to investigate, essentially in [parseGradleCommand](https://github.com/expo/eas-cli/blob/deaa3a9105d55a56d9e9b9ee80cee4860d8a3a9f/packages/eas-cli/src/project/android/gradleUtils.ts#L67) neither `flavorDimensions` nor `productFlavors` are being found
I tried to debug the parser and... well, I discovered that I don't _want_ to debug a parser right now. However I've noticed that my keys are being parsed, but they're in the wrong place:
### Managed or bare?
Bare
### Environment
expo-env-info 1.2.2 environment info:
System:
OS: macOS 15.0
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.18.0 - ~/.asdf/installs/nodejs/20.18.0/bin/node
Yarn: 4.3.1 - ~/.asdf/installs/nodejs/20.18.0/bin/yarn
npm: 10.8.2 - ~/.asdf/plugins/nodejs/shims/npm
Managers:
CocoaPods: 1.16.2 - /Users/gabrielrohden/.asdf/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 24.2, iOS 18.2, macOS 15.2, tvOS 18.2, visionOS 2.2, watchOS 11.2
Android SDK:
API Levels: 28, 30, 33, 34, 35
Build Tools: 34.0.0, 35.0.0, 36.0.0
System Images: android-34 | Google APIs ARM 64 v8a, android-34 | Google Play ARM 64 v8a, android-34 | Google Play Intel x86_64 Atom, android-35 | Google Play ARM 64 v8a, android-35 | Pre-Release 16 KB Page Size Google Play ARM 64 v8a
IDEs:
Xcode: 16.2/16C5032a - /usr/bin/xcodebuild
npmPackages:
expo: ^52.0.0 => 52.0.23
react: 18.3.1 => 18.3.1
react-dom: ^18.3.1 => 18.3.1
react-native: 0.76.5 => 0.76.5
npmGlobalPackages:
eas-cli: 14.4.0
Expo Workflow: bare
### Error output
```
Unable to read gradle project config: flavor staging is not defined.
log.js:55Values from app/build.gradle might be resolved incorrectly.
log.js:55Error: Failed to autodetect applicationId in multi-flavor project.
```
### Reproducible demo or steps to reproduce from a blank project
I didn't setup any runtime/test of this cli codebase, but I think that this file might help to pinpoint where the parser is failing
```gradle
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"
apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")
import com.android.build.OutputFile
react {
debuggableVariants = ["debug"]
autolinkLibrariesWithApp()
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
bundleCommand = "export:embed"
}
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc-intl:+'
android {
buildFeatures {
buildConfig true
}
ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion
namespace "com.rnproject"
defaultConfig {
applicationId "com.rnproject"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled true
versionName "3.29.0"
versionCode 1731069170
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
buildConfigField "String", "BRAZE_ANDROID_API_KEY", "\"${System.getenv("BRAZE_ANDROID_API_KEY")}\""
buildConfigField "String", "SUNSHINE_ANDROID_API_KEY", "\"${System.getenv("SUNSHINE_ANDROID_API_KEY")}\""
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
flavorDimensions "env"
productFlavors {
staging {
dimension "env"
applicationId 'com.rnproject'
}
production {
dimension "env"
applicationId 'com.rnproject'
}
}
}
dependencies {
implementation("com.facebook.react:react-android")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}
apply plugin: 'com.google.gms.google-services'
```
Contributor guide
Assessment
This issue has not been assessed yet.