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

来源:互联网 发布:淘宝最大的网店 编辑:程序博客网 时间:2024/05/14 04:30

今天在手机上运行调试的项目时候提示

    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"))}

所以出现这个问题,解决办法在调试的时候先注释掉这部分代码,打包的时候再添加上吧,或者封装的时候就不要把时间添加上了

阅读全文
0 0
原创粉丝点击