簡體   English   中英

任務“installDebug”在項目“:app”中不明確 - 使用 android 風格的 React Native

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

我正在嘗試使用以下命令運行反應原生應用程序:`react-native run-android –variant=devDebug`

但我得到了錯誤:

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'.

事實上,當我在項目的 android 文件夾中運行 gradlew 任務時,我找不到 installDebug。

我不知道我應該做些什么來解決這種情況。

一些背景:我正在嘗試實現 Android 風格,以在同一手機/設備上安裝開發和產品應用程序。 當我在 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"
        }
    }

任何想法? 非常感謝!

當我使用此命令時,expo 裸工作流面臨同樣的問題

expo run:android --variant 'development'

並看到同樣的錯誤

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

所以我嘗試使用expo run:android --variant 'developmentDebug'並且有效並且沒有收到模棱兩可的錯誤。 我想由於每種風格都可以有debugrelease構建類型,我們需要清楚地告訴它我們想要哪一種。

但是,在 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/

我也面臨同樣的問題 reactnative old version.like this

  • 出了什么問題:任務“installDebug”在項目“:app”中不明確。 候選對象是:'installProductionDebug'、'installProductionDebugAndroidTest'、'installStagingDebug'、'installStagingDebugAndroidTest'。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM