Sígvardr Ólavrsson Sígvardr Ólavrsson - 9 months ago 81
Android Question

Android studio fail to install app on device

I have a Samsung Galaxy S5 device running Android 4.4.2
it was working just fine until a few weeks a go I started getting this issue, Android Studio fail to install the app after I press run and build the gradle

Additional information : I tried to run the app on an emulatir the first time it work and after I did some changes I tried to run on the emulator again but the changes were noy applied

This is the gradle file :

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.incorp.anisvikernes.appex"
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName "1.0"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:cardview-v7:23.1.0'

This is the LogCat :

03:49:45 Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources]
03:51:04 Gradle build finished in 1m 18s 412ms
05:23:54 Executing tasks: [:app:assembleDebug]
05:28:19 Gradle build finished in 4m 25s 153ms
05:28:32 Error during Sync: An existing connection was forcibly closed by the remote host
05:28:32 Session 'app': Error Installing APK

This is the error

08/20 05:28:26: Launching app
$ adb push D:\projects\appex\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.incorp.anisvikernes.appex
java.io.IOException: An existing connection was forcibly closed by the remote host
Error while Installing APK

Answer Source

I actually found a solution that fixed this problem, it will seem really odd and wierd but after updating my driver (Win key+x -> device manager -> going to my device and pressing update button) I changed the USB cable used to connect the phone to my PC and it worked immediately