当我尝试在Android Studio上调试应用程序时,给出了以下日志输出:

APK文件 /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk没有 存在于磁盘上。

我重启了Android Studio,但是我无法解决这个问题。我怎么解决呢? 谢谢你!


当前回答

在我的例子中,我在应用程序文件路径中使用了一个特殊字符。我关闭了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)
    }
}

如果你在更新到Android Studio V 3.1后遇到这个问题,那么试试下面的方法。

当我更新到Android Studio 3.1时,我也遇到了同样的问题。我在这里找到的所有其他解决方案都是手动的,因为你每次都必须清理和重建,这一点都不好。但是多亏了Iman Marashi的回答,我才得以解决这个问题。

执行->编辑配置…

确保你有一个Gradle-aware Make在Before launch部分:

要添加它,点击+号,然后选择Gradle-aware Make,一个弹出窗口就会出现,只需要让文本字段为空,然后点击OK和OK。

对我来说,只是

查看>工具Windows > Gradle >右键单击[项目]>刷新Gradle项目

    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'
            }
        }

在我的案例中,问题是调试配置不知何故变得无效,即使测试方法名称、类或包没有改变。

我删除配置从运行->编辑配置,在这里:

Android studio会自动创建一个新的。