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

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

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


当前回答

我已经解决了使用顶部窗口和构建apk的构建选项构建apk。没必要做什么奇怪的事。

其他回答

assemble[Variant]会在磁盘上为你生成APK,尽管不需要使用它来调试应用程序。

在工程项目根目录下执行如下命令:

$ ./gradlew clean build assemble[Variant]

GL

我的问题是我将版本号附加到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)
    }
}

在gradle 1.5中也遇到了同样的问题

我必须清理构建文件:

Build ->清洁项目

并构建一个APK来强制gradle文件的完整编译和同步:

Build -> Build APK

但我还是不知道为什么会这样。

修改文件:build。gradle (app目录)。 其实:你不应该更改这个文件,只需要通过这个来获得同步技巧,然后同步项目。

我改变体型。gradle文件的一些信息,然后点击“现在同步”,就可以了。