简体   繁体   English

react-native android 项目未找到错误

[英]react-native android project not found error

I am trying to create a react-native project using react-native cli.我正在尝试使用 react-native cli 创建一个 react-native 项目。 Command I used to create project我用来创建项目的命令

  • npx react-native init test npx react-native 初始化测试

After this if I try to run this app by在此之后,如果我尝试通过以下方式运行此应用程序

  • cd test & npx react-native run-android cd 测试 & npx react-native run-android

But I get this error:但我得到这个错误:

error Android project not found.找不到错误 Android 项目。 Are you sure this is a React Native project?你确定这是一个 React Native 项目吗? If your Android files are located in a non-standard location (eg not inside 'android' folder), consider setting project.android.sourceDir option to point to a new location.如果您的 Android 文件位于非标准位置(例如不在“android”文件夹内),请考虑将project.android.sourceDir选项设置为指向新位置。

I have android, ios folder in root project and node version is 16.15.0我在根项目中有 android, ios 文件夹,节点版本为 16.15.0

This is my project json:这是我的项目 json:

 { "name": "test", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint." }, "dependencies": { "react": "17.0.2", "react-native": "0.68.2" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", "babel-jest": "^26.6.3", "eslint": "^7.32.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.67.0", "react-test-renderer": "17.0.2" }, "jest": { "preset": "react-native" } }

I was facing the same issue too so i've created a thread on r/reactnative and someone kind provided a solution.我也面临同样的问题,所以我在 r/reactnative 上创建了一个线程,并且有人提供了解决方案。 Not sure why, but it works for me.不知道为什么,但它对我有用。 The solution is:解决方案是:

  1. delete node_modules删除节点模块
  2. add this to package.json: "resolutions": { "glob": "7.2.0" }将此添加到 package.json: "resolutions": { "glob": "7.2.0" }
  3. install node_modules with yarn or npm使用 yarn 或 npm 安装 node_modules

https://www.reddit.com/r/reactnative/comments/uphynu/hello_there_is_a_new_error_i_guess/ https://www.reddit.com/r/reactnative/comments/uphynu/hello_there_is_a_new_error_i_guess/

The issue comes after glob@7.2.2 was released.这个问题是在 glob@7.2.2 发布之后出现的。 Follow the following steps and recompile the project.按照以下步骤重新编译项目。

  1. Clear node_modules清除 node_modules
  2. add this to package.json "resolutions": { "glob": "7.2.0" }将此添加到 package.json "resolutions": { "glob": "7.2.0" }
  3. Reinstall node_modules with npm install使用 npm install 重新安装 node_modules

If this not work try this command如果这不起作用,请尝试此命令

" yarn add glob@7.2.0" “纱线添加 glob@7.2.0”

Update on the tagged date.更新标记日期。 I had the same error on a new install.我在新安装时遇到了同样的错误。 version 0.69.0 had problems finishing the install. 0.69.0 版在完成安装时出现问题。 Suggestion from github that I install new project with the previous version github 建议我用以前的版本安装新项目

npx react-native init ProjectName --version 0.68.2

https://github.com/facebook/react-native/issues/34055 https://github.com/facebook/react-native/issues/34055

I fixed mine by using cortinico's answer from https://github.com/facebook/react-native/issues/34055#issuecomment-1165887713我通过使用来自https://github.com/facebook/react-native/issues/34055#issuecomment-1165887713的 cortinico 的回答修复了我的问题

The issue is caused by having some globally installed Yarn/NPM packages which is not generally recommended.该问题是由于全局安装了一些通常不推荐的 Yarn/NPM 包引起的。

Depending on the commands you installed in the past with -g, you should be able to cleanup your environment with a combination of those commands:根据您过去使用 -g 安装的命令,您应该能够使用这些命令的组合来清理您的环境:

yarn global remove react-native
yarn global remove react-native-cli
npm uninstall -g react-native
npm uninstall -g react-native-cli

Make sure the global packages are clean with:确保全局包是干净的:

yarn global list
npm -g list

(check that nothing react-native related is available in those lists). (检查这些列表中是否没有与 react-native 相关的内容)。

Afterwards you can then simply install using:之后,您可以使用以下命令简单地安装:

npx react-native init PROJECT_NAME

暂无
暂无

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

相关问题 react-native run-android 问题 - 找不到错误 Android 项目 - react-native run-android issue - error Android project not found AAPT:错误:资源 android:未找到属性/lStar。 React-native项目 - AAPT: error: resource android:attr/lStar not found. React-native project 运行react-native run-android --variant = release时出错(在根项目'gnosisapp'中找不到任务'installReleaseDebug'。) - Error running react-native run-android --variant=release (Task 'installReleaseDebug' not found in root project 'gnosisapp'.) Android Studio/react-native 项目:无法删除 gradle 错误:未找到 ID 为“com.android.library”的插件 - Android Studio/react-native project: Unable to remove gradle error: Plugin with id 'com.android.library' not found 尝试运行android react-native项目时出错 - Getting error when try to run android react-native project 尝试为 React-Native Android 项目启动 logKitty 时出错 - Error when trying to start logKitty for React-Native Android Project 找不到用于本机反应的 Android SDK - Android SDK not found for react-native 找不到错误 Android 项目。 你确定这是一个 React Native 项目吗? - error Android project not found. Are you sure this is a React Native project? 建立Apk React-Native项目时出错 - Error in building apk react-native project 在现有项目React-Native中添加现有的本机项目Android - Add existing native project Android in exist project React-Native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM