【发布时间】:2019-07-24 15:24:11
【问题描述】:
我最近买了一台新电脑。我已经使用 git 下载了我的项目并使用 android studio 启动它。现在,当我运行应用程序(代码没有更改)时,该过程将挂在“安装 APK”或“安装”上。一分钟或五分钟后,Android Studio 将提示我一条消息,告诉我以下内容: “安装失败,消息为空。通过卸载现有版本的 apk(如果存在),然后重新安装,可能会解决此问题。”
需要注意的一点可能是该项目之前已经安装并在 Android 设备上运行(并且在首次尝试新安装时尚未删除)
我已经检查了几件事,但最重要的是:
- 我的 Android 设备上不再安装该应用程序。
- 即时运行已关闭(正如互联网上多次建议的那样)。
- 一个全新的项目可以在 Android 设备上正常运行(因此它不能是设备或电缆)
我猜 gradle 文件是最重要的:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "some.package.name"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:support-v4:28.0.0-alpha3'
implementation 'com.android.support:support-media-compat:28.0.0-alpha3'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
implementation 'com.android.support:design:28.0.0-alpha3'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'org.apache.directory.studio:org.apache.commons.io:2.4'
implementation 'com.google.code.gson:gson:2.8.5'
}
【问题讨论】:
-
您是否要安装在实际设备的模拟器中?
-
不,我的硬件不支持模拟。因此我被真实设备卡住了
-
尝试重置亚行。我曾经发生过类似的事情,并通过 ADB 重置修复了它。如果这不起作用,请尝试通过 ADB 命令行安装 apk。
-
检查您的构建选项卡!
-
我会在我再次访问我的电脑后立即尝试(必须在摆姿势后去)。否则,重启 Android Studio 是否也应该重启 ADB?在那种情况下,我已经尝试过了。 (否则我会稍后再试)
标签: android android-studio apk