正如標題中所寫,當我從 expo 開始時應用程式會執行,但是當我嘗試yarn react-native run-android在 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'.
即使我在 android 中創建了一個名為 local.properties 的檔案并寫了
sdk.dir=D\:\\AndroidSDK
這兩個代碼在做不同的作業嗎?如果編碼部分有問題,為什么其中一個執行沒有任何問題?
uj5u.com熱心網友回復:
React Native 有兩種解決方法:
React Native CLI - 適用于需要原生模塊和手動配置 Android Studio 和 Xcode 的應用程式。
Expo CLI - SDK 構建在 React Native 之上。Expo 提供易于使用的工具和 API 以及由云 Expo Server 基礎架構完成的原生模塊編譯。
通過運行expo start,Expo CLI 會啟動一個服務器,為您的設備或模擬器上的 Expo Go 應用程式提供您的應用程式代碼。您的本地設備上不會發生本機模塊編譯,也不需要 Android SDK。
另一方面,在運行時yarn react-native run android,必須安裝并配置 Java JDK 和 Android SDK 才能編譯原生模塊。
在https://reactnative.dev/docs/environment-setup探索更多資訊
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/406376.html
標籤:
