简体   繁体   English

找不到用于本机反应的 Android SDK

[英]Android SDK not found for react-native

There are multiple similar questions everywhere across the internet and so far no provided solutions work.互联网上到处都有多个类似的问题,到目前为止还没有提供有效的解决方案。
I use Android Studio 4.0.0, and maybe this is the problem.我使用 Android Studio 4.0.0,也许这就是问题所在。

So far I got these settings in my system variables:到目前为止,我在我的系统变量中得到了这些设置:
环境变量

Also PATH variable:还有 PATH 变量:
路径变量

Here is what react-native info outputs:这是 react-native info 输出的内容:

$ react-native info
info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.18363
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
    Memory: 23.08 GB / 31.86 GB
  Binaries:
    Node: 12.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Version  4.0.0.0 AI-193.6911.18.40.6514223
  Languages:
    Java: 11.0.2 - /c/Users/zarifov/AppData/Local/jdk-11.0.2/bin/javac
    Python: 2.7.18 - /c/Python27/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: ~16.11.0 => 16.11.0
    react-native: ~0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found

And also, just in case, react-native doctor output:而且,以防万一,react-native doctor 输出:

$ react-native doctor
Common
 ✓ Node.js
 ✓ yarn
 ✓ Python

Android
 ✓ JDK
 ✓ 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: 28.0.3
 ✓ ANDROID_HOME

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.
Common
 ✓ Node.js
 ✓ yarn
 ✓ Python

Android
 ✓ JDK
 ✓ 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: 28.0.3
 ✓ ANDROID_HOME

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.

Additional important information: The attempt to fix issue with SDK via doctor cannot be successful since it fails with "permission denied" on attempting to install Androd Command Line Tools despite the fact that the PowerShell and IDE are launched with admin privileges.其他重要信息:尽管 PowerShell 和 IDE 是以管理员权限启动的,但尝试通过 doctor 修复 SDK 问题的尝试无法成功,因为它在尝试安装 Androd 命令行工具时失败并显示“权限被拒绝”。

I have a solution: install Android SDK Command-line Tools:我有一个解决方案:安装 Android SDK 命令行工具:

在此处输入图像描述

I had exactly this problem and managed to solve it by doing something simple:我确实遇到了这个问题,并设法通过做一些简单的事情来解决它:

In the 'gradle-wrapper.properties' file, I changed the version of the gradle in distributionUrl value.在“gradle-wrapper.properties”文件中,我更改了distributionUrl值中 gradle 的版本。

It was like that distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip and I changed to distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip . It was like that distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip and I changed to distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip

Now it's working!!现在它正在工作!

I had this same issue.我有同样的问题。 Mine was even showing that:我的甚至表明:

    Android
 ✓ JDK
 ✖ 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: 29.0.3
 ✓ ANDROID_HOME

Errors:   2
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.

在此处输入图像描述

I got fed up with all the steps that are online that are not working and just clicked on 'e'.我厌倦了在线上所有不起作用的步骤,只是点击了“e”。 It took its time and installed the said missing programs (note that I already installed Android studio and all the SDK instructions on react-native docs before now but for some reason it was not being detected)花了一些时间并安装了上述缺失的程序(请注意,我之前已经安装了 Android 工作室和 react-native 文档上的所有 SDK 说明,但由于某种原因它没有被检测到)

When I ran npx react-native doctor , the issue was resolved:当我运行npx react-native doctor时,问题得到了解决:

在此处输入图像描述

Install Android SDK command line tool along with desired Android SDK build tool .安装Android SDK 命令行工具以及所需的Android SDK 构建工具 Then check npx react-native doctor然后检查npx react-native doctor

You must install support libraries, you can do this by opening Android Studio, SDK manager and install support library version 28.0.3您必须安装支持库,您可以通过打开 Android Studio、SDK 管理器并安装支持库版本 28.0.3 来完成此操作

在此处输入图像描述

在此处输入图像描述

i can see package deatils.我可以看到 package 细节。 its look lik this enter image description here它看起来像这样在此处输入图像描述

The correct way of solving it involves a two-step process.解决它的正确方法包括两个步骤。 This is what worked for me:这对我有用:

STEP 1步骤1

Install Android SDK Command-line tools .安装Android SDK 命令行工具 After doing so, once you call npx react-native doctor you'll no longer see Versions found: N/A (providing that you already have some SDK version(s) installed in your machine, which I assume is the case).这样做之后,一旦您调用npx react-native doctor ,您将不再看到Versions found: N/A (前提是您的机器上已经安装了一些 SDK 版本,我假设是这种情况)。 After installing it you should see something like:安装后你应该看到如下内容:

安装 Android SDK 命令行工具后的 react-native doctor

STEP 2第2步

If version found does not match the version react-native supports ( version supported ) then you need to download the correct SDK version to make them match.如果找到的版本与 react-native 支持的版本不匹配( version supported )那么你需要下载正确的 SDK 版本来使它们匹配。 When doing so you need to be careful as you have to do two more steps within android studio menus: tools --> sdk manager --> Android SDK .这样做时你需要小心,因为你必须在 android studio 菜单中再执行两个步骤: tools --> sdk manager --> Android SDK Once here:曾经在这里:

STEP 2.1 Select SDK Platforms and choose Platform and Sources for you API Level (tick "show package details" checkbox):步骤 2.1选择SDK Platforms并为您的 API 级别选择平台和来源(勾选“显示包详细信息”复选框):

在此处输入图像描述

STEP 2.2 Select SDK Tools and tick the box of the API version you need to install to match it with react needs (again make sure you tick "show package details" checkbox): STEP 2.2选择SDK Tools并勾选您需要安装的 API 版本的框以使其与 React 需求相匹配(再次确保勾选“显示包详细信息”复选框):

在此处输入图像描述

Now click OK and install everything.现在单击“确定”并安装所有内容。 Close your terminal and run it again.关闭您的终端并再次运行它。 When using react-native doctor comand you'll find the problem is solved:当使用react-native doctor comand 你会发现问题解决了:

在此处输入图像描述

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM