Ste*_*ath 12 android react-native
我正在尝试在android模拟器上运行我的项目。运行时,react-native run-android我得到以下信息:
FAILURE: Build failed with an exception.
* What went wrong: Task 'installDebug' not found in root project 'android'.
* Try: Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Run Code Online (Sandbox Code Playgroud)
如果我跑步,./gradlew tasks我会得到:
Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]
Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'android'.
components - Displays the components produced by root project 'android'. [incubating]
dependencies - Displays all dependencies declared in root project 'android'.
dependencyInsight - Displays the insight into a specific dependency in root project 'android'.
help - Displays a help message.
model - Displays the configuration model of root project 'android'. [incubating]
projects - Displays the sub-projects of root project 'android'.
properties - Displays the properties of root project 'android'.
tasks - Displays the tasks runnable from root project 'android'.
Run Code Online (Sandbox Code Playgroud)
知道为什么我的项目中没有installDebug任务吗?我该如何找回?
小智 9
用于调试测试
react-native run-android --variant devKernelDebug
原因是因为在文件 android/build.gradle 中我们有这个
productFlavors {
devKernel {
dimension 'remoteKernel'
}
prodKernel {
dimension 'remoteKernel'
}
}
Run Code Online (Sandbox Code Playgroud)
小智 8
react-native运行android --variant [productFlavorName] [debug / release]
例如react-native run-android --variant Huaweidebug
我曾在新鲜的反应母语相同的问题项目(react-native init projectname)后,running react-native start然后react-native run-android在VS代码。它给出了这个错误
Task 'installDebug' not found in project ':app'.
Run Code Online (Sandbox Code Playgroud)
它在 RN "0.62.1"
解决方案:- 我打开 Android Studio,然后清理并重建。
我不确定在清理和重建后它会起作用。
我也做了并在根项目中给出了 sdk 路径
export ANDROID_HOME=/home/mycomputer/Android/Sdk/
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Run Code Online (Sandbox Code Playgroud)
然后它起作用了。
我的 npm 版本6.7.0 我的 Node 版本v11.10.1 react-native-cli: 2.0.1 react-native: 0.62.1
我已经解决了这个问题你只需要在 Android 文件夹中创建文件
去安卓文件夹
创建文件 local.properties
然后只需在 local.properties 文件中添加此代码:-
如果您使用的是 MacBook,那么 sdk.dir=/Users/USERNAME/Library/android/sdk
如果您使用的是 Windows,则 sdk.dir=C:\Users\USERNAME\AppData\Local\Android\sdk
如果您使用的是 Linux,则 sdk.dir = /home/USERNAME/Android/sdk
如果你想知道你的系统用户名是什么,那么只需使用 Mac whoami 命令
然后只需重新运行命令 react-native run-android
谢谢 :)
我也遇到了另一个问题
此版本中使用了已弃用的 Gradle,使其与 Gradle 7.0 不兼容。
在 Android 构建中作为附加的屏幕截图。
在用 android studio 打开 android 文件夹并让它由 android studio 构建时,问题得到解决。在那之后运行
npx react-native run-android
,它工作正常。
cd android
./gradlew clean
cd..
react-native run-android --variant=DevDebug
Run Code Online (Sandbox Code Playgroud)
这对我来说是固定的
| 归档时间: |
|
| 查看次数: |
6388 次 |
| 最近记录: |