当我尝试在Android Studio上调试应用程序时,给出了以下日志输出:
APK文件 /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk没有 存在于磁盘上。
我重启了Android Studio,但是我无法解决这个问题。我怎么解决呢? 谢谢你!
当我尝试在Android Studio上调试应用程序时,给出了以下日志输出:
APK文件 /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk没有 存在于磁盘上。
我重启了Android Studio,但是我无法解决这个问题。我怎么解决呢? 谢谢你!
当前回答
首先通过编辑配置来删除cleaner,它可能在构建apk后清理构建。
Click on edit from set run/debug then click on gradle list select the clean project item and then click on -(top 2nd from left).
其他回答
在gradle 1.5中也遇到了同样的问题
我必须清理构建文件:
Build ->清洁项目
并构建一个APK来强制gradle文件的完整编译和同步:
Build -> Build APK
但我还是不知道为什么会这样。
1) This problem occure due to apk file .if your apk file
(output/apk/debug.apk) not generated in this format .
2) you should use always in gradle file .
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
对我来说,问题是它无法找到apk,尽管apk存在。
The APK file /Users/Paul/AndroidStudioProjects/android-tv-launcher/ui/build/outputs/apk/nameofapk.apk does not exist on disk.
Error while Installing APK
我所要做的,就是右键点击apk-copy相对路径,然后
adb install -r <paste of relative path>
apk已经安装好了。 这个问题发生在OSX上。
在我的例子中,我在应用程序文件路径中使用了一个特殊字符。我关闭了Android Studio并从我的应用程序文件路径中删除了'字符。当我重新启动项目时,一切都很正常。
我的问题是我将版本号附加到APK。更改版本号和重新同步Gradle为我解决了这个问题。
def appendVersionNameVersionCode(variant, defaultConfig) {
variant.outputs.each { output ->
if (output.zipAlign) {
def file = output.outputFile
def removeApp = file.name.replace("app-", "")
def removeType = removeApp.replace("-release", "")
def fileName = removeType.replace(".apk", "." + defaultConfig.versionName + ".apk")
output.outputFile = new File(file.parent, fileName)
}
def file = output.packageApplication.outputFile
def removeApp = file.name.replace("app-", "")
def removeType = removeApp.replace("-release", "")
def fileName = removeType.replace(".apk", "." + defaultConfig.versionName + ".apk")
output.packageApplication.outputFile = new File(file.parent, fileName)
}
}