Home > Software design >  No problem when starting app with "expo start" but problem when opening "yarn react-n
No problem when starting app with "expo start" but problem when opening "yarn react-n

Time:01-09

As written in the header, app executes when I start with expo, but many problem lines when I try to run with yarn react-native run-android in Vscode.

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'.

Even if I created a file named local.properties inside android and wrote

sdk.dir=D\:\\AndroidSDK

Are these two codes doing different jobs? If the coding part is problematic, why one of them executes without any problem?

CodePudding user response:

There are 2 workarounds with React Native:

  1. React Native CLI - For an app that requires native modules and manual configuration of Android Studio and Xcode.

  2. Expo CLI - SDK builds on top of React Native. Expo provides easy-to-use tools and APIs and native module compilation done by cloud Expo Server infrastructure.

By running expo start, Expo CLI starts a server to serve your app code to the Expo Go app on your device or emulator. There's no native module compilation happening on your local device and no need for Android SDK.

On another side, when you run yarn react-native run android, the Java JDK and Android SDK must be installed and configured to compile native modules.

Explore more at https://reactnative.dev/docs/environment-setup

  •  Tags:  
  • Related