您的位置:首页 > 移动开发

The APK file D:\Code\Air\app\build\outputs\apk\.apk does not exist on disk.

2017-12-06 11:15 756 查看
今天在手机上运行调试的项目时候提示

Session 'app': Error Installing APK


再看具体日志提示:

The APK file D:\Code\Air\app\build\outputs\apk\.apk does not exist on disk.


尝试了,rebuild,clean,restart等等方法未果,后来google,不得不说google的强大,查到一篇这样的文章:

https://stackoverflow.com/questions/39765345/the-apk-file-does-not-exist-on-disk-but-it-does

对比一下,我正好在gradle中封装了打包的日期,如下:

applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
def fileName
if (outputFile != null && outputFile.name.endsWith('.apk')) {
// 输出apk名称为XXapp1.4.0_2017-02-14.apk
if (variant.buildType.name.equals('release')) {
fileName = "air_${defaultConfig.versionCode}_v${defaultConfig.versionName}_${releaseTime()}_${debugTime()}_release.apk"
} else if (variant.buildType.name.equals('debug')) {
fileName = "air_${defaultConfig.versionCode}_v${defaultConfig.versionName}_${releaseTime()}_${debugTime()}_debug.apk"
}
output.outputFile = new File(outputFile.parent, fileName)
}
}
}


项目gradle中添加了时间:

def releaseTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("GMT+8"))
}
def debugTime() {
return new Date().format("HH-mm", TimeZone.getTimeZone("GMT+8"))
}


所以出现这个问题,解决办法在调试的时候先注释掉这部分代码,打包的时候再添加上吧,或者封装的时候就不要把时间添加上了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  session apk 谷歌