应用程序将无法在模拟器上运行

问题描述 投票:0回答:2

我正在使用react-native开发一个Android应用程序我已经设置了我的Android环境但是在运行react-native run-android之后我收到此错误:

Scanning 577 folders for symlinks in /home/user/laravel/Code/mikwe-app/node_modules (5ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library
09:23:43 E/DeviceMonitor: Connection attempts: 6
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library UP-TO-DATE
:app:prepareComFacebookFrescoDrawee101Library UP-TO-DATE
:app:prepareComFacebookFrescoFbcore101Library UP-TO-DATE
:app:prepareComFacebookFrescoFresco101Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipeline101Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineBase101Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineOkhttp3101Library UP-TO-DATE
:app:prepareComFacebookReactReactNative0472Library UP-TO-DATE
:app:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE
:app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:bundleDebugJsAndAssets SKIPPED
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug
:app:packageDebug UP-TO-DATE
:app:assembleDebug UP-TO-DATE
:app:installDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1.196 secs
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/android-setup.html

我已经在互联网上查看了不同的解决方案,建议重新启动adb-server,但这一切都没有用。

我也试过列出我的设备:

 adb devices
 List of devices attached
adb server is out of date.  killing...
* daemon started successfully *
emulator-5554   offline

但是我有一个正在运行的模拟器:enter image description here

我正在寻找解决这个问题的解决方案。

android react-native react-native-android
2个回答
1
投票

我在模拟器上运行时看到了同样的问题(Linux Mint 17.2,react-native-cli:2.0.1,react-native:0.55.4,node v8.11.2)。似乎模拟器在编译后立即脱机。

导致失败的程序:

  • 启动模拟器
  • 检查设备

$ adb devices

附加设备列表

模拟器-5554设备

设备正常,继续运行:

$ react-native run-android

......一些(编译)片刻之后

跳过设备'emulator-5554'(模拟器-5554):设备脱机。:app:installDebug FAILED

电话上不存在该问题。我确实玩过这个问题,似乎模拟器大部分都失败了。但是,我找到了一个启动模拟器的调整,并成功上传并启动了代码。我没时间深入了解原因。

我的调整过程是在模拟器仍在启动时运行react-native run-android命令。在仿真器已经完全启动之后。有时我不止一次点击命令,因为如果模拟器没有达到正确的阶段,它将会失败(显然)。不是最后阶段,因为它将再次脱机。请注意,在立即重新运行react-native run-android命令时不需要重新编译,因此它很快并且模拟器不可能启动。我还从模拟器中擦除数据,使其加载速度变慢。

在模拟器中安装应用程序后,您可以从模拟器启动。如果您还在控制台上运行npm start,则可以对应用程序重新加载较小的更改。需要重新编译时,需要再次进行调整。除非需要重新编译,否则我不会从模拟器中擦除数据。

如果有更多这样的情况,可能值得进一步调查这一点。请让我知道调整是否也为您的案例提供了解决方法。此外,请注意,根据我的测试,从Android Studio启动应用程序可以解决此问题。因此,使用Android Studio是另一种解决方法。


0
投票

我以前遇到过同样的问题我通过重启模拟器修复了它,因为有时它正在运行但是停止响应

© www.soinside.com 2019 - 2024. All rights reserved.