React Native:由于找不到 Android SDK(版本 33.0.0)而出现“无法安装应用程序”错误

问题描述 投票:0回答:1

我是 React Native 新手,在开始我的第一个项目时遇到了困难。我已按照 React Native 的安装步骤进行操作,包括设置 Java、Android Studio 和相关 SDK 文件。我还为 Android 配置了必要的环境变量,如附图所示。

尽管遵循了所有安装步骤,但我在尝试初始化新的 React Native 项目时遇到了问题。它没有按预期工作,我在设置 React Native 项目时遇到问题。当我运行

npx react-native doctor
时,我收到以下错误消息:

错误:

error Failed to install the app.
PS D:\Visual Studio Code\Projects\React Native\AwesomeProject> npx react-native doctor
Common
 ✓ Node.js - Required to execute JavaScript code
 ✓ yarn - Required to install NPM dependencies

Android
 ✓ Adb - Required to verify if the android device is attached correctly
 ✓ JDK - Required to compile Java code
 ✓ Android Studio - Required for building and installing your app on Android
 ✖ Android SDK - Required for building and installing your app on Android
   - Versions found: N/A
   - Version supported: 33.0.0
 ✓ ANDROID_HOME - Environment variable that points to your Android SDK installation

Errors:   1
Warnings: 0

Usage
 › Press f to try to fix issues.
 › Press e to try to fix errors.
 › Press w to try to fix warnings.
 › Press Enter to exit.

即使我安装了 Android Studio,似乎也没有检测到 Android SDK。以下是我为解决该问题所采取的步骤:

  1. 安装Android Studio并确认它包含Android SDK。
  2. ANDROID_HOME
    环境变量设置为正确的路径。
  3. 将 Android SDK 的
    platform-tools
    子目录添加到我系统的 PATH 变量中。
  4. 检查并确认使用Android Studio中的SDK Manager安装了33.0.0版本对应的Android SDK组件。

尽管执行了这些步骤,我仍然遇到该错误。有人可以帮我解决并解决这个问题吗?任何指导或见解将不胜感激。

操作系统:Windows Android Studio版本:2022.3.1.19 反应本机版本:0.72.4

我想要一个相关的解决方案来解决这个问题

javascript react-native android-studio android-sdk-tools android-sdk-manager
1个回答
0
投票

试试这个:

cd android

chmod +x gradlew

./gradlew clean

然后运行您的应用程序

© www.soinside.com 2019 - 2024. All rights reserved.