Reactjs 无法在android emulator上运行react本机应用程序

Reactjs 无法在android emulator上运行react本机应用程序,reactjs,react-native,react-native-android,react-native-ios,Reactjs,React Native,React Native Android,React Native Ios,当我运行npm运行android时,我在react native上升级,但不知道如何解决这个问题,我在下面遇到了这个错误。但当我运行npm运行IOS时,它在IOS上运行良好。我不知道错误是否来自模拟器 > react-native run-android info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found

当我运行npm运行android时,我在react native上升级,但不知道如何解决这个问题,我在下面遇到了这个错误。但当我运行npm运行IOS时,它在IOS上运行良好。我不知道错误是否来自模拟器

> react-native run-android

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1757 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :react-native-select-contact
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.2.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '27.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Task :app:installDebug FAILED
[EmulatorConsole]: Failed to start Emulator console for 5554
01:28:40 V/ddms: execute: running am get-config
01:28:40 V/ddms: Got reply 'FAIL', diag='closed'
01:28:40 E/ddms: ADB rejected shell command (am get-config): closed
01:28:40 V/ddms: execute: returning

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
281 actionable tasks: 2 executed, 279 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: com.android.ddmlib.AdbCommandRejectedException: closed

* 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 28s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: com.android.ddmlib.AdbCommandRejectedException: closed

* 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 28s

    at checkExecSyncError (child_process.js:607:13)
    at execFileSync (child_process.js:627:13)
    at runOnAllDevices (/Users/comname/Documents/Test/newapp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
    at buildAndRun (/Users/comname/Documents/Test/newapp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
    at then.result (/Users/comname/Documents/Test/newapp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! memong@0.0.1 android: `react-native run-android`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the memong@0.0.1 android script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/comname/.npm/_logs/2020-03-23T12_28_41_531Z-debug.log
我试过npm运行android-deviceId xxxxxxxxx,但我仍然有同样的问题。。。有什么问题吗?

我有这个问题。 它似乎无法建造。请按照以下步骤解决此问题。 1-转到android目录。 2-./gradlew installDebug-stacktrace 尝试解决发生的异常。在“原因”部分中,您可以看到更多详细信息。 构建成功后,返回到项目目录,并尝试react native run android

创建文件local.properties 将此行添加到此文件sdk.dir=C\:\\Users\\Admin\\AppData\\Local\\Android\\sdk 最后将local.properties文件添加到android文件夹中 尝试运行本地android
adb设备的命令提供了什么输出?如果您在linux中,您是否尝试在项目文件夹上运行sudo npm start,然后在另一个终端运行react native run android?