react-native-community / cli

The React Native Community CLI - command line tools to help you build RN apps
MIT License
2.32k stars 897 forks source link

run-android with --mode fails without error info (after upgrading to v72.5) #2105

Closed fikkatra closed 10 months ago

fikkatra commented 10 months ago

Environment

System: OS: macOS 14.0 CPU: (8) arm64 Apple M1 Pro Memory: 104.59 MB / 32.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.15.0 path: /usr/local/bin/node Yarn: version: 1.22.19 path: /usr/local/bin/yarn npm: version: 9.5.0 path: /usr/local/bin/npm Watchman: version: 2023.10.02.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.13.0 path: /Users/fikkatra/.rbenv/shims/pod SDKs: iOS SDK: Platforms:

Description

After following the guide to upgrade from 71 to 72, we get an error when running Android.

The command: react-native run-android --mode=myAppDevDebug --appId com.myapp.dev

fails with the following output (and nothing else):

info JS server already running.

info šŸ’” Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

error Failed to install the app.

Except from following the steps mentioned in the upgrade guide, and updating library versions, nothing has changed.

We have the following product flavors defined:

    flavorDimensions "default"
    productFlavors {
        myappdev {
            applicationId "com.myapp.dev"
            manifestPlaceholders = [appAuthRedirectScheme: 'com.myapp.auth.dev']
        }
        myapptst {
            applicationId "com.myapp.tst"
            manifestPlaceholders = [appAuthRedirectScheme: 'com.myapp.auth.tst']
        }
        myappprd {
            applicationId "com.myapp.prd"
        }
    }

Additional info

Is there any way we can get more error info? I tried adding the --verbose flag, but the output is the same.

szymonrybczak commented 10 months ago

Hey @fikkatra, thanks for creating issue! It is really well described! Some time ago we were working on improving error messages and I think we added some regressions and the proper error is not shown. Adding this code to build.gradle causes this error:

error Couldn't find "MyAppDevDebug" build variant. Available variants are: "MyappdevDebug", "MyappdevRelease", "MyappprdDebug", "MyappprdRelease", "MyapptstDebug", "MyapptstRelease".

So you should change variant (to MyappdevDebug) which you pass to the command (I'm not sure why this is happening, but that's how Gradle returns it). I hope that helps šŸ™Œ

fikkatra commented 10 months ago

@szymonrybczak thank you so much for looking into it. Indeed you are right: changing the casing of the variant fixed it.

Since we've been using these variants successfully for ages, this means something regarding the casing of variants must have changed with the update (gradle 8)?