简体   繁体   中英

Task 'installDebug' is ambiguous in project ':app' - React Native with android flavors

I am trying to run a react native app with the command: `react-native run-android –variant=devDebug``

But I get the the error:

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
(node:20659) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /Users/[username]/code/[app_name]/node_modules/tslib/package.json.
Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)

FAILURE: Build failed with an exception.

* What went wrong:
Task 'installDebug' is ambiguous in project ':app'. Candidates are: 'installDevDebug', 'installDevDebugAndroidTest', 'installProdDebug', 'installProdDebugAndroidTest', 'installStagingDebug', 'installStagingDebugAndroidTest'.

Indeed when I run gradlew tasks in the android folder of my project, I can't find installDebug.

I don't know what I am supposed to do to solve this situation.

Some contex: I am trying to implement Android flavours, to install a dev and a prod app on the same phone/device. When I remove the following in build.gradle, the command react-native run-android runs fine (without the --version param):

    flavorDimensions "env"
    productFlavors {
        dev {
            resValue "string", "app_name", "MyApp Dev"
            applicationIdSuffix ".dev"
        }
        staging {
            resValue "string", "app_name", "MyApp Stag"
            applicationIdSuffix ".stag"
        }
        prod {
            resValue "string", "app_name", "MyApp"
        }
    }

Any idea? Thanks a lot!

Facing same issue with expo bare workflow when I am using this command

expo run:android --variant 'development'

and seeing the same error

FAILURE: Build failed with an exception.
* What went wrong:
Task 'installDevelopment' is ambiguous in project ':app'. Candidates are: 'installDevelopmentDebug', 'installDevelopmentDebugAndroidTest', 'installDevelopmentRelease'

So I tried with expo run:android --variant 'developmentDebug' and that worked and didn't received the ambiguous error. I suppose as each flavour can have debug and release build type, we need to tell it clearly which one we want.

However, in case of expo I received another error after that

Couldn't start project on Android: Error running adb: The development client (<package>) for this project is not installed. Please build and install the client on the device first.
Learn more: https://docs.expo.dev/clients/distribution-for-android/

I am also facing same issue reactnative old version.like this

  • What went wrong: Task 'installDebug' is ambiguous in project ':app'. Candidates are: 'installProductionDebug', 'installProductionDebugAndroidTest', 'installStagingDebug', 'installStagingDebugAndroidTest'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM