#android #react-native #react-native-android
#Android #react-native
Вопрос:
У меня возникла проблема при работе над проектом React Native на платформе macOS. Мой проект корректно работает на симуляторе IOS, но не работал на эмуляторе Android.
Вот журнал ошибок:
JS server already running.
Building and installing the app on the device (cd android amp;amp; ./gradlew installDebug)...
> Configure project :app
WARNING: The specified Android SDK Build Tools version (28.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '28.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
> Task :app:checkDebugClasspath FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find react-native.jar (com.facebook.react:react-native:0.58.4).
Searched in the following locations:
file:/Users/asena/Desktop/deneme/Deneme/node_modules/react-native/android/com/facebook/react/react-native/0.58.4/react-native-0.58.4.jar
* 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 1s
1 actionable task: 1 executed
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Command failed: ./gradlew installDebug
Error: Command failed: ./gradlew installDebug
at checkExecSyncError (child_process.js:637:11)
at Object.execFileSync (child_process.js:655:13)
at runOnAllDevices (/Users/asena/Desktop/deneme/Deneme/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
at buildAndRun (/Users/asena/Desktop/deneme/Deneme/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
at isPackagerRunning.then.result (/Users/asena/Desktop/deneme/Deneme/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
Как я могу исправить эту проблему? Каково ваше предложение?
Спасибо,
Ответ №1:
Вероятно, у вас просто установлена другая версия React Native.
Быстрое и грязное исправление — просто изменить версию на "com.facebook.react:react-native: "
.
Что может быть лучше, так это зайти в ваши node_modules, найти актуальную версию пакета и изменить версию в вашем скрипте gradle, чтобы она соответствовала.