我正在尝试使用以下命令运行 react native 应用程序: `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 bare 工作流程相同的问题
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'
并且有效并且没有收到不明确的错误。我想由于每种风格都可以有 debug
和 release
构建类型,我们需要清楚地告诉它我们想要哪一种。
但是,如果是世博会,我会收到另一个错误
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/
关于android - 任务 'installDebug' 在项目 ':app' 中不明确 - React Native 与 android 风格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73113282/