【问题标题】:Android studio fail to install app on deviceAndroid Studio 无法在设备上安装应用程序
【发布时间】:2016-12-27 07:02:32
【问题描述】:

我有一台运行 Android 4.4.2Samsung Galaxy S5 设备 它工作得很好,直到几周前我开始遇到这个问题,Android Studio 在我按下运行并构建 gradle 后无法安装应用程序

其他信息:我第一次尝试在模拟器上运行该应用程序,在我做了一些更改后,我尝试再次在模拟器上运行,但没有应用更改

这是 gradle 文件:

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'
} 

这是 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

这是错误

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

【问题讨论】:

  • 重建、清理和重新运行
  • 缓存重启无效。
  • VVB 这不是一个永久的解决方案,它并不总是有效,@Sohail Zahid 请问我该怎么做呢??
  • 位于项目设置下方。
  • @SohailZahid 不幸的是,缓存无效并没有解决我的问题

标签: android android-studio gradle build ioexception


【解决方案1】:

我解决了同样的问题

1. Disable USB debugging and developer options
2. Disconnect the device from USB 
3. Re enable USB debugging and developer options
4. Reconnect device 

当时有人说我在杀死并重新启动 adb 时遇到了问题。

【讨论】:

  • 这不起作用,我尝试从任务管理器和终端中杀死 adb,但我仍然遇到同样的问题
【解决方案2】:

我实际上找到了一个解决这个问题的解决方案,它看起来真的很奇怪而且很奇怪,但是在 更新我的驱动程序之后(Win key+x -> 设备管理器 -> 转到我的设备并按下更新按钮)我更换了用于将手机连接到我的 PC 的 USB 数据线,它立即工作了

【讨论】:

    【解决方案3】:

    在数小时未成功后,移除 USB 延长线对我有用。 除了您描述的安装 APK 过程之外,任何与 USB 扩展电缆一起工作的东西。也许其他人可以通过将 USB 电缆更改为短而稳定的工作电缆来解决它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多