Android build flavors break `expo run:android`

Bare workflow

eas --version
eas-cli/0.55.1 darwin-arm64 node-v16.14.0

I followed these instructions to add another flavor to my Android build. I added this to my android/app/build.gradle:

flavorDimensions "env"
productFlavors {
    production {
        dimension "env"
        applicationId '{removed}'
    }
    qa {
        dimension "env"
        applicationId '{removed}'
    }
}

Then I updated my eas.json file so my build.development.android.gradleCommand is “:app:assembleQaDebug”.

Finally I ran expo run:android and selected my connected device, which proceeded to build my app, which succeeded with BUILD SUCCESSFUL. It then started Metro, showed the QR code, and proceeded to the install step which failed with this:

FAILURE: Build failed with an exception.

* What went wrong:
Task 'installDebug' is ambiguous in project ':app'. Candidates are: 'installProductionDebug', 'installProductionDebugAndroidTest', 'installQaDebug', 'installQaDebugAndroidTest'.

* Try:
> Run gradlew tasks to get a list of available tasks.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 8s
6 actionable tasks: 6 up-to-date
/Users/{removed}/android/gradlew exited with non-zero code: 1
Error: /Users/{removed}/android/gradlew exited with non-zero code: 1
    at ChildProcess.completionListener (/Users/{removed}/.nvm/versions/node/v16.14.0/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:65:13)
    at Object.onceWrapper (node:events:640:26)
    at ChildProcess.emit (node:events:520:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
    ...
    at spawnAsync (/Users/{removed}/.nvm/versions/node/v16.14.0/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:26:19)
    at spawnGradleAsync (/Users/{removed}/.nvm/versions/node/v16.14.0/lib/node_modules/expo-cli/src/commands/run/android/spawnGradleAsync.ts:83:18)
    at installAsync (/Users/{removed}/.nvm/versions/node/v16.14.0/lib/node_modules/expo-cli/src/commands/run/android/spawnGradleAsync.ts:72:16)
    at actionAsync (/Users/{removed}/.nvm/versions/node/v16.14.0/lib/node_modules/expo-cli/src/commands/run/android/runAndroid.ts:161:11)

Opening the android folder and manually running ./gradlew :app:installQaDebug installed the build on my connected device without issue.

Since the build command defined in eas.json was successful, but the install command run by the eas-cli just used the original :app:installDebug command rather than the command it should be using (which worked manually for me) it seems like this is a bug in the cli. Anyone else have this issue?

I figured it out. When using variants, you need to declare the variant you are using in the run command, e.g.: expo run:android --variant=qaDebug

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.