在macOS Catalina上找不到adb
我开始学习如何在android环境下使用ReactNative进行移动编程。我正在使用MacOS Catalina,我已经安装了android studio和react native cli。我运行了在macOS Catalina上找不到adb,macos,react-native,android-studio,adb,platform-tools,Macos,React Native,Android Studio,Adb,Platform Tools,我开始学习如何在android环境下使用ReactNative进行移动编程。我正在使用MacOS Catalina,我已经安装了android studio和react native cli。我运行了react native init ShoppingList,它通过了 Downloading template, Copying template, Processing template 但是在安装CocoaPods依赖项时失败了,因为我还不是最新的操作系统(我希望这不是问题的一部分,因
react native init ShoppingList
,它通过了
Downloading template,
Copying template,
Processing template
但是在安装CocoaPods依赖项时失败了,因为我还不是最新的操作系统(我希望这不是问题的一部分,因为我没有足够的内存升级操作系统)
我参考了里面的一条建议,要求我跑步
npm uninstall -g react-native react-native-cli
npm install -g react-native react-native-cli
react-native start --reset-cache
我还删除了项目根目录下的node_模块和npm install
。然后在项目的根目录下,我运行了react native run android
这给了我以下的错误
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
/bin/sh: adb: command not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/prashin/Test/ShoppingList/android/local.properties'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
在Android Studio中,安装了以下组件
Android 11.0(R),
Android SDK Build-Tools,
Android Emulator 30.2.6,
Android SDK-Platform-Tools 30.0.5,
Intel x86 Emulator Accelerator (HAXM installer) 7.5.1
我用发行名R(API级别30)创建了一个Pixel 2设备
,并无数次按下播放按钮,这给了我一个AVD管理器的错误:无法找到ADB
这是我的.bash\u配置文件
文件
source ~/.profile
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
##
# Your previous /Users/prashin/.bash_profile file was backed up as /Users/prashin/.bash_profile.macports-saved_2019-10-23_at_18:32:04
##
# MacPorts Installer addition on 2019-10-23_at_18:32:04: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
export ANDROID_HOME=/Users/prashin/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH="$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"
# export PATH="$PATH:/Users/$USER/Library/Android/sdk/platform-tools"
# export PATH=${PATH}:/usr/local/mysql-5.7.31-macos10.14-x86_64/bin
# Finished adapting your PATH environment variable for use with MacPorts.
我确实看到了平台工具中的adb可执行文件
在这里,我可能遗漏了什么阻止我在模拟器上运行我的基本应用程序?如果需要更多信息,一定要通知我
编辑
建议切换到.zprofile
的解决方案改为更改了错误消息。在产生下面的错误之前,它在info-launcing-emulator
上被卡住了30秒
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
> Task :app:installDebug FAILED
Skipping device 'emulator-5554' (emulator-5554): Device is OFFLINE.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
27 actionable tasks: 2 executed, 25 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No online devices found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
对于Catalina,苹果将默认shell更改为zsh。因此,您必须重命名配置文件。
.bashrc
现在是.zshrc
,而现在是.zprofile
。将.bash\u配置文件的内容移动到新的.zprofile
文件中,然后重新启动终端。使用新的环境变量再次运行应用程序。只需重新启动终端,我就成功了…虽然现在出现了播放
按钮和react native Run android
的模拟器,但我仍然在“找不到adb”的播放
按钮上遇到错误。对于该命令,错误已更改为“无法在30秒内启动emulator”。我已经在我的原始帖子中粘贴了完整的错误消息。你能试着运行adb设备,看看你的设备是否被列在设备列表中吗?我试着根据这篇帖子设置Catalina,我只看到emulator-5544 unauthorized
,此处的预期输出是什么?能否尝试adb kill server
并再次运行adb设备
?。Android模拟器默认情况下启用USB调试。如果一切正常,你就会得到这样的东西<代码>emulator-5544设备
我仍然返回相同的输出。它总是说启动模拟器,然后30秒它说它是离线的