Cli: [Android] Upgrade of CLI from 3.x to 4.x (with RN 0.62) breaks --appIdSuffix

Created on 31 Mar 2020  路  5Comments  路  Source: react-native-community/cli

Environment

System:
    OS: macOS 10.15.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 594.50 MB / 32.00 GB
    Shell: 3.1.0 - /usr/local/bin/fish
  Binaries:
    Node: 10.16.3 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.0 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.3/11C29 - /usr/bin/xcodebuild
  Languages:
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: 0.62.0 => 0.62.0
  npmGlobalPackages:
    *react-native*: Not Found

Description

We're using an applicationIdSuffix in our apps gradle file for debug, which we run with npx react-native run-android --appIdSuffix debug

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            signingConfig signingConfigs.debug
        }
    }

This has worked thus far with the CLI v3.x, but as we upgraded our project to React Native 0.62.0, the CLI was upgraded to v4.4.

Now we're getting the following error when the app builds, running the same command:

$ react-native run-android --appIdSuffix debug
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1976 file(s) to forward-jetify. Using 16 workers...
info JS server already running.
info Installing the app...

<snip>

FAILURE: Build failed with an exception.

* What went wrong:
Task 'installDebugDebug' not found in project ':app'.

Reproducible Demo

Sample project: https://github.com/cbrevik/suffixExample

Note: I've just generated a 0.62 project with npx react-native init, and added an extra commit on top of that with applicationIdSuffix: https://github.com/cbrevik/suffixExample/commit/d6129ec0b79adaab38f5641eadec88e0faeb0493

bug needs triage android

Most helpful comment

Sure! This seems like the bug: https://github.com/react-native-community/cli/commit/19ac71f02c0ececa669afb26dce2cb02f0de23f6#diff-b668aefc66b33ed6e984d3467db0abc1R54 (concat appIdSuffix to variant in order to generate the task name).

The workaround for me was to just overwrite the task name, with:

react-native run-android --tasks installDebug --appIdSuffix debug

Even though that works, it seems like the options should work in a different way.

As far as I understand, a build variant in Android is the full name of the build type with the flavor. So for example the build type could be debug, while the flavor could be demo, which makes the build variant demoDebug. I'm not an expert at gradle though, so 馃し鈥嶁檪

In this case, the appIdSuffix should only be used when launching the app, not when building it. I think the appIdSuffix doesn't have to be the same as the build type, so concatenating the suffix + variant probably isn't a good idea?

So maybe it's better if people specify the "full" variant name to build with --variant while --appIdSuffix only helps the CLI launch the correct package.

I've commited a fix here; https://github.com/AtB-AS/cli/commit/bd297f4bbae6cb5af0442a3bb01ff82cf766d39e

I'd love to open a PR in this case, if it seems like the right solution.

All 5 comments

Thanks for the repro, we'll try to prioritize this. I suspect these might be commits that introduced this regression: https://github.com/react-native-community/cli/pull/1029, https://github.com/react-native-community/cli/pull/1053. Any help with debugging this and contributing a fix is greatly appreciated 馃槉

Sure! This seems like the bug: https://github.com/react-native-community/cli/commit/19ac71f02c0ececa669afb26dce2cb02f0de23f6#diff-b668aefc66b33ed6e984d3467db0abc1R54 (concat appIdSuffix to variant in order to generate the task name).

The workaround for me was to just overwrite the task name, with:

react-native run-android --tasks installDebug --appIdSuffix debug

Even though that works, it seems like the options should work in a different way.

As far as I understand, a build variant in Android is the full name of the build type with the flavor. So for example the build type could be debug, while the flavor could be demo, which makes the build variant demoDebug. I'm not an expert at gradle though, so 馃し鈥嶁檪

In this case, the appIdSuffix should only be used when launching the app, not when building it. I think the appIdSuffix doesn't have to be the same as the build type, so concatenating the suffix + variant probably isn't a good idea?

So maybe it's better if people specify the "full" variant name to build with --variant while --appIdSuffix only helps the CLI launch the correct package.

I've commited a fix here; https://github.com/AtB-AS/cli/commit/bd297f4bbae6cb5af0442a3bb01ff82cf766d39e

I'd love to open a PR in this case, if it seems like the right solution.

@Krizzu what do you think? ^

I agree that CLI params naming are bit misleading here, so I'm up for the change.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thymikee picture thymikee  路  4Comments

jchook picture jchook  路  4Comments

ferrannp picture ferrannp  路  4Comments

tallpants picture tallpants  路  4Comments

lucasbento picture lucasbento  路  3Comments