磁盘上不存在.apk文件,但它确实存在

Waq*_*ari 5 android apk android-studio

每当我调试应用程序时,都会出现错误,... .apk file does not exist on a disk并且应用程序无法启动.

更新Android Studio后,此错误开始发生.

经过大量的搜索,我尝试了不同的解决方案.这包括:

  1. 降级Android Studio(它开始提供插件错误,我不想不能使用新的Android Studio)
  2. 试试这个解决方案没有运气.
  3. 迎合了不同的问题,但可能解决我的问题.它也不起作用.
  4. 提到了这个问题

任何帮助将不胜感激.

小智 6

如果你在build.gradle文件中有这样的东西:

applicationVariants.all { variant ->
    variant.outputs.each { output ->
         output.outputFile = new File(output.outputFile.parent, baseFilename + defaultConfig.versionCode + "_" + defaultConfig.versionName + "_" + getDate() + ".apk")
    }
}
Run Code Online (Sandbox Code Playgroud)

还有这个

def getDate() {
    def date = new Date()
    def formattedDate = date.format('dd.MM.yyyy')
    return formattedDate
}
Run Code Online (Sandbox Code Playgroud)

您应该从输出中删除getDate()以修复您的问题.看看这篇文章也是如此.


SAI*_*AIR 2

检查你的 apk 的路径。文件夹名称中可能有一些特殊字符。这也会导致 adb 通过此错误。