Seb*_*ian 5 android react-native
I've followed the installation instructions for ReactNative on the official site but can't get my project to build and install on any device. The issue seems to be that ReactNative can't seem to locate my Android SDK.
If I open the Android specific part of the project in Android Studio I can start the app, so the SDK is properly installed. Maybe related is also that I'm working on a Flutter app simultaneously and Flutter has no problems locating the Android SDK.
Running nix react-native doctor gives me the following:
Common
? Node.js
? yarn
? Watchman - Used for watching changes in the filesystem when in development mode
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.2
? ANDROID_HOME
iOS
? Xcode - Required for building and installing your app on iOS
? CocoaPods - Required for installing iOS dependencies
? ios-deploy - Required for installing your app on a physical device with the CLI
Errors: 1
Warnings: 0
Attempting to fix 1 issue...
Android
? Android SDK
Read more about how to download Android SDK at https://reactnative.dev/docs/getting-started
Run Code Online (Sandbox Code Playgroud)
However trying to "fix" the issue just takes me to the getting started page, and as I mentioned before I've done the installation exactly as described. I even tried removing everything related to Android from my computer and reinstalling everything from scratch.
Runnit nix react-native info gives me the following:
info Fetching system and libraries information...
System:
OS: macOS 10.15.4
CPU: (8) x64 Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz
Memory: 1.97 GB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.16.3 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6514223
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Java: 14.0.1 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/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
Run Code Online (Sandbox Code Playgroud)
Which just further "proves" that ReactNative can't find the Android SDK.
What I've tried so far:
Adding a local.properties with the content:
sdk.dir=/Users/[username]/Library/Android/sdk
Run Code Online (Sandbox Code Playgroud)
(是的,该文件夹存在并且是正确的,它与 Android Studio 中的设置相同)
更新.zshrc:
export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
Run Code Online (Sandbox Code Playgroud)
在那个 sdk 文件夹中(在平台中)我有android-28,android-29和android-30. 我也(当然)看过一些有同样问题的人的帖子,但是这两个修复程序中的一个几乎总是可以解决问题,但是它对我不起作用。还有什么可以测试的?
更新:我还可以在运行时添加它npx react-native run-android并 tget 错误:Task 'installDebug' not found in project ':app'.。但是这个问题也应该用 来解决properties.local,这对我不起作用。
小智 10
我发现在 Android Studio 中安装“Android SDK 命令行工具”插件将允许医生识别更新的 android sdk 实例!
但是它与 react-native 不兼容,我们需要29.0.2,所以一定要检查“显示包详细信息”并在下载之前选择正确的版本。
之后我的npx react-native doctor输出:
michel@michel-ubuntu:~/development/projects/Project$ rn doctor
Common
? Node.js
? npm
Android
? JDK
? Android Studio - Required for building and installing your app on Android
? Android SDK - Required for building and installing your app on Android
? ANDROID_HOME
Errors: 0
Warnings: 0
Common
? Node.js
? npm
Android
? JDK
? Android Studio - Required for building and installing your app on Android
? Android SDK - Required for building and installing your app on Android
? ANDROID_HOME
Errors: 0
Warnings: 0
Run Code Online (Sandbox Code Playgroud)
在 (mac m1) 上修复此问题的步骤:
确保您已在 ~/.zshrc 中添加 JAVA_HOME
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
Run Code Online (Sandbox Code Playgroud)
正如环境设置中所述,您只需安装Android 13 (Tiramisu)即可。
确保检查以下项目:
然后配置环境变量:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
Run Code Online (Sandbox Code Playgroud)
确保通过选中显示包复选框来安装 SDK 构建工具版本 33 和
SDK 命令行工具版本 33。
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/10.0/bin
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5580 次 |
| 最近记录: |