React Native:未找到 Android 项目.也许先运行 react-native android? [英] React native: Android project not found. Maybe run react-native android first?

查看:53
本文介绍了React Native:未找到 Android 项目.也许先运行 react-native android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 React-Native 项目中遇到了一个问题,该项目之前运行良好,但突然停止工作.每当我使用命令时:

I had an issue in my React-Native project which was working fine earlier but suddenly it stopped working. Whenever I used the command:

react-native run-android

我收到一个错误:

未找到 Android 项目.也许先运行 react-native android?

Android project not found. Maybe run react-native android first?

尝试运行:

react-native android

但它说:

无法识别的命令 'android' 运行 react-native --help 查看列表所有可用命令

尝试后:

D:\ProjectRoot\ReactNativeProjects\AwesomeProject>react-native eject

返回的错误是:

扫描文件夹中的符号链接D:\ProjectRoot\ReactNativeProjects\AwesomeProject\node_modules (48ms)应用 name 必须在 app.json 配置文件中定义以定义项目名.不得包含任何空格或破折号.

Scanning folders for symlinks in D:\ProjectRoot\ReactNativeProjects\AwesomeProject\node_modules (48ms) App name must be defined in the app.json config file to define the project name. It must not contain any spaces or dashes.

这是 app.json 文件:

This is the app.json file:

{
  "expo": {
    "name": "AwesomeProject",
    "description": "A very interesting project.",
    "slug": "AwesomeProject",
    "privacy": "public",
    "sdkVersion": "30.0.0",
    "platforms": ["ios", "android"],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "package": "com.project.first"
    },
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ]
  }
}

推荐答案

打开你的 React Native 项目根目录并找到 android -> app -> build -> middles ->signing_config -> debug -> out ->signing-config.json .删除signing-config.json这个文件再试一次

Open your React Native Project Root Directory and locate android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json . delete signing-config.json this file try again

1) 有时如果我们有旧版本的 react native 并且一些新安装的包不支持旧版本.然后你必须使用 react-native upgrade 命令更新 react native 项目.

1)Sometimes if we have older version of react native and some of newly installed packages dose not support older version. Then you have to update the react native project using react-native upgrade command.

  1. 将当前项目更新到新版本后,此错误应该会解决.

这篇关于React Native:未找到 Android 项目.也许先运行 react-native android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆