执行任务':app:installDebug'的时间最多为TIMES

时间:2019-01-23 21:07:46

标签: react-native

有很多关于该错误的在线帖子。我的情况是我有时可以建立连接,但大多数时候都失败了。这是失败时的错误:

PTHREAD_CANCELED

这是成功时的消息:

PTHREAD_CANCELED

我没有很好的解释,为什么有时它起作用了,而有时却没有。在每个PS C:\d\code\js\chatapp> react-native run-android JS server already running. Building and installing the app on the device (cd android && gradlew.bat installDebug)... Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details 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. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 15s 27 actionable tasks: 1 executed, 26 up-to-date 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 之前,在Mate 9上启用PS C:\d\code\js\chatapp> react-native run-android JS server already running. Building and installing the app on the device (cd android && gradlew.bat installDebug)... > Task :app:installDebug Installing APK 'app-debug.apk' on 'MHA-L29 - 8.0.0' for app:debug Installed on 1 device. BUILD SUCCESSFUL in 6s 27 actionable tasks: 1 executed, 26 up-to-date 'adb' is not recognized as an internal or external command, operable program or batch file. Starting the app (c:\AppData\Local\Android\Sdk/platform-tools/adb shell am start -n com.chatapp/com.chatapp.MainActivity... Starting: Intent { cmp=com.chatapp/.MainActivity }

3 个答案:

答案 0 :(得分:1)

我遇到了类似的问题,刚刚在这里发布了一个对我有用的解决方案 - https://stackoverflow.com/a/67566428/10392546

我遇到了类似的问题,不确定你是否解决了它,但我在寻找解决方案时遇到了这篇文章,但上述解决方案对我不起作用。

我发现的一个解决方案是安装 android-emulator-m1-preview from google,然后启动它,而不是从 Android Studio 内部启动模拟器。原来要解决的问题是如此简单,这几乎令人讨厌。

在尝试不同的解决方案 12 多个小时后看到构建成功真是太好了。

答案 1 :(得分:0)

当我连接的手机屏幕锁定时,也会发生这种情况。尝试运行时,请确保手机处于“活动状态”。在运行react-native run-android之前,可以使用“ adb devices”命令列出所有连接的设备。确保一次只有一个(也没有运行模拟器)。 我可以建议的最后一件事是更新React Native。他们在每个版本的改进方面都做得很出色,有可能您将永远不会在最新版本中再次看到此错误。祝好运!

答案 2 :(得分:0)

我的项目有这个问题。我尝试了很多方法来解决这个问题,我在 stackoverflow、github、博客文章中有很多指导方针。但是我在这个过程中犯了一个错误。所以请确保你在调试期间做事。

  1. 运行cd android && ./gradlew clean && ./gradlew :app:bundleRelease

  2. 确保在每个动作中擦除模拟器中的数据

  3. 如果您尝试使用外部设备,请确保它在线或解锁屏幕。