使用 "expo start" 启动应用程序时没有问题,但打开 "yarn react-native run-android" 时出现问题
No problem when starting app with "expo start" but problem when opening "yarn react-native run-android"
如 header 中所写,应用程序在我从 expo 开始时执行,但是当我尝试 运行 和 Vscode 中的 yarn react-native run-android
时出现许多问题行。
warning ..\package.json: No license field
$ "C:\Users\SAMSUNG\Desktop\React Native Projects\Uber\node_modules\.bin\react-native" run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1075 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
'adb' is not recognized as an internal or external command,
operable program or batch file.
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...
> Configure project :expo
BUILD FAILED in 19s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Error: Autolinking is not set up in `settings.gradle`: expo modules won't be autolinked.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> 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 'C:\Users\SAMSUNG\Desktop\React Native Projects\Uber\android\local.properties'.
即使我在 android 中创建了一个名为 local.properties 的文件并写入
sdk.dir=D\:\AndroidSDK
这两个代码在做不同的工作吗?如果编码部分有问题,为什么其中一个执行没有问题?
React Native 有 2 种解决方法:
React Native CLI - 对于需要本机模块和手动配置 Android Studio 和 Xcode.
的应用程序
Expo CLI - SDK 建立在 React Native 之上。 Expo 提供易于使用的工具和 API 以及由云 Expo Server 基础架构完成的本机模块编译。
通过 运行ning expo start
,Expo CLI 启动一个服务器,将您的应用程序代码提供给您设备或模拟器上的 Expo Go 应用程序。您的本地设备上没有本地模块编译,也不需要 Android SDK。
另一方面,当您运行 yarn react-native run android
时,必须安装和配置Java JDK 和Android SDK 才能编译本机模块。
探索更多
如 header 中所写,应用程序在我从 expo 开始时执行,但是当我尝试 运行 和 Vscode 中的 yarn react-native run-android
时出现许多问题行。
warning ..\package.json: No license field
$ "C:\Users\SAMSUNG\Desktop\React Native Projects\Uber\node_modules\.bin\react-native" run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1075 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
'adb' is not recognized as an internal or external command,
operable program or batch file.
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...
> Configure project :expo
BUILD FAILED in 19s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Error: Autolinking is not set up in `settings.gradle`: expo modules won't be autolinked.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> 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 'C:\Users\SAMSUNG\Desktop\React Native Projects\Uber\android\local.properties'.
即使我在 android 中创建了一个名为 local.properties 的文件并写入
sdk.dir=D\:\AndroidSDK
这两个代码在做不同的工作吗?如果编码部分有问题,为什么其中一个执行没有问题?
React Native 有 2 种解决方法:
React Native CLI - 对于需要本机模块和手动配置 Android Studio 和 Xcode.
的应用程序Expo CLI - SDK 建立在 React Native 之上。 Expo 提供易于使用的工具和 API 以及由云 Expo Server 基础架构完成的本机模块编译。
通过 运行ning expo start
,Expo CLI 启动一个服务器,将您的应用程序代码提供给您设备或模拟器上的 Expo Go 应用程序。您的本地设备上没有本地模块编译,也不需要 Android SDK。
另一方面,当您运行 yarn react-native run android
时,必须安装和配置Java JDK 和Android SDK 才能编译本机模块。