npx react-native run-android:E/设备:同步期间出错:EOF

fre*_*hme 7 android gradle build.gradle react-native

我正在尝试在我真正的 Android 设备上运行 React Native 应用程序。我在跑步前检查了我的设备

adb devices

List of devices attached
3357425441473098        device
Run Code Online (Sandbox Code Playgroud)

我开始于

npx react-native start
Run Code Online (Sandbox Code Playgroud)

并在其他控制台中

npx react-native run-android
Run Code Online (Sandbox Code Playgroud)

但出现错误..

Task :app:installDebug FAILED                                                                                                                                                     
10:25:40 V/ddms: execute: running am get-config                                                                                                                                     
10:25:40 V/ddms: execute 'am get-config' on '3357425441473098' : EOF hit. Read: -1                                                                                                  
10:25:40 V/ddms: execute: returning                                                                                                                                                 
Installing APK 'app-debug.apk' on 'SM-G960U - 9' for app:debug                                                                                                                      
10:25:40 D/app-debug.apk: Uploading app-debug.apk onto device '3357425441473098'                                                                                                    
10:25:40 D/Device: Uploading file onto device '3357425441473098'                                                                                                                    
10:25:40 D/ddms: Reading file permision of /home/user/react-native/awesomeProject/android/app/build/outputs/apk/debug/app-debug.apk as: rw-rw-r--                
10:25:40 D/ddms: read: channel EOF                                                                                                                                                  
10:25:40 E/Device: Error during Sync: EOF                                                                                                                                           
Unable to install /home/user/react-native/awesomeProject/android/app/build/outputs/apk/debug/app-debug.apk                           
com.android.ddmlib.InstallException: EOF      
Run Code Online (Sandbox Code Playgroud)

就在那个错误之后。我失去了设备连接。

adb devices
Run Code Online (Sandbox Code Playgroud)

什么也没显示..

在堆栈跟踪的底部我也看到了这个错误

Caused by: java.io.IOException: EOF
        at com.android.ddmlib.AdbHelper.read(AdbHelper.java:862)
        at com.android.ddmlib.SyncService.doPushFile(SyncService.java:712)
        at com.android.ddmlib.SyncService.pushFile(SyncService.java:406)
        at com.android.ddmlib.Device.syncPackageToDevice(Device.java:988)
        at com.android.ddmlib.Device.installPackage(Device.java:902)
Run Code Online (Sandbox Code Playgroud)

失败:构建失败并出现异常。

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

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

    at checkExecSyncError (child_process.js:629:11)
    at execFileSync (child_process.js:647:13)
    at runOnAllDevices (/home/user/react-native/newProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevice
s.js:94:39)
    at buildAndRun (/home/user/react-native/newProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
    at then.result (/home/user/react-native/newProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Run Code Online (Sandbox Code Playgroud)

我的设备是美国三星 Galaxy s9。当我使用Expo sdk时它可以工作。我的问题是什么?

反应本机:0.61.5

奇怪的是它在计算机启动后首先执行。然后我尝试重新连接手机,它再次弹出。

jlb*_*lca 3

刚刚遇到了同样的问题。结果发现是我的 USB 数据线的问题。由于某种原因,安装过程因设备离线而被中断。我更换了电缆,一切又开始工作了。