简体   繁体   English

任务“installDebug”在项目“:app”中不明确 - 使用 android 风格的 React Native

[英]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``我正在尝试使用以下命令运行反应原生应用程序:`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.事实上,当我在项目的 android 文件夹中运行 gradlew 任务时,我找不到 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.一些背景:我正在尝试实现 Android 风格,以在同一手机/设备上安装开发和产品应用程序。 When I remove the following in build.gradle, the command react-native run-android runs fine (without the --version param):当我在 build.gradle 中删除以下内容时,命令react-native run-android运行良好(没有 --version 参数):

    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 裸工作流面临同样的问题

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.所以我尝试使用expo run:android --variant 'developmentDebug'并且有效并且没有收到模棱两可的错误。 I suppose as each flavour can have debug and release build type, we need to tell it clearly which one we want.我想由于每种风格都可以有debugrelease构建类型,我们需要清楚地告诉它我们想要哪一种。

However, in case of expo I received another error after that但是,在 expo 的情况下,之后我收到另一个错误

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我也面临同样的问题 reactnative old version.like this

  • What went wrong: Task 'installDebug' is ambiguous in project ':app'.出了什么问题:任务“installDebug”在项目“:app”中不明确。 Candidates are: 'installProductionDebug', 'installProductionDebugAndroidTest', 'installStagingDebug', 'installStagingDebugAndroidTest'.候选对象是:'installProductionDebug'、'installProductionDebugAndroidTest'、'installStagingDebug'、'installStagingDebugAndroidTest'。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复错误说“任务:app:installDebug FAILED”,同时在android studio中运行我的反应本机项目? - How to fix error saying “Task :app:installDebug FAILED”, while run my react native project in android studio? 在项目“:app”中找不到任务“installDebug”(npx react-native run-android 问题) - Task 'installDebug' not found in project ':app'(npx react-native run-android issue) React Native-任务&#39;:app:installDebug&#39;的执行失败 - React Native - Execution failed for task ':app:installDebug' React Native:任务:应用程序:安装调试失败 - React Native: Task :app:installDebug FAILED React-Native 项目卡在:app:installDebug - React-Native project stuck on :app:installDebug 在项目“:app”中找不到任务“installDebug”。仅在一个 react-native 项目中 - Task 'installDebug' not found in project ':app'.in only one react-native project 在根项目“android”React Native 中找不到“installDebug” - 'installDebug' not found in root project 'android' React Native 尝试在 MI MAX 2 android 设备上运行本机应用程序时应用程序安装调试任务期间出现安全异常 - SecurityException during app:installDebug Task while attempting to run react-native app on MI MAX 2 android device 任务':app:installDebug'的执行失败反应本机应用程序 - Execution failed for task ':app:installDebug' react native app React-Native(Android)错误:任务:app:installDebug FAILED(macOs Big Sur) - React-Native (Android) error : Task :app:installDebug FAILED (macOs Big Sur)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM