I’m attempting to build an Android project and test it on my device. Usually, when I try to push the build to my device either through the Unity Build Settings menu (Build and Run option) or manually through the adb install command, I receive an error and the build fails:
adb: error: failed to copy 'C:\Users\Path\To\Project\Temp\StagingArea\Package.apk' to '/data/local/tmp/Package.apk': no response: Connection reset by peer
I also see an stdout print in the log that shows the progress ticking upward. When the connection is reset and fails to build, the final percentage is anywhere between 0% - 99%. Here is a sample:
stdout[
[ 0%] /data/local/tmp/Package.apk
[ 0%] /data/local/tmp/Package.apk
[ 0%] /data/local/tmp/Package.apk
[ 0%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 2%] /data/local/tmp/Package.apk
[ 2%] /data/local/tmp/Package.apk
...
[ 41%] /data/local/tmp/Package.apk
However, by disconnecting my device from my PC or rebuilding, I can sometimes (as in, very rarely) successfully push to the device.
Has anyone else encountered this “Connection reset by peer” issue when attempting to install via adb? The error message prompts me to check my Android SDK installation, though the build process will sometimes succeed. Here is the full error message, with the stdout portion truncated:
Error building Player: CommandInvokationFailure: Unable to install APK to device. Please make sure the Android SDK is installed and is properly configured in the Editor. See the Console for more details.
C:/Android\platform-tools\adb.exe -s "64d32755" install -r "C:\Users\Path\To\Project\Temp\StagingArea\Package.apk"
stderr[
]
stdout[
[ 0%] /data/local/tmp/Package.apk
[ 0%] /data/local/tmp/Package.apk
[ 0%] /data/local/tmp/Package.apk
[ 0%] /data/local/tmp/Package.apk
[ 0%] /data/local/tmp/Package.apk
[ 0%] /data/local/tmp/Package.apk
[ 0%] /data/local/tmp/Package.apk
[ 0%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 1%] /data/local/tmp/Package.apk
[ 2%] /data/local/tmp/Package.apk
[ 2%] /data/local/tmp/Package.apk
...
[ 41%] /data/local/tmp/Package.apk
adb: error: failed to copy 'C:\Users\Path\To\Project\Temp\StagingArea\Package.apk' to '/data/local/tmp/Package.apk': no response: Connection reset by peer
]