当我尝试在Android Studio上调试应用程序时,给出了以下日志输出:
APK文件 /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk没有 存在于磁盘上。
我重启了Android Studio,但是我无法解决这个问题。我怎么解决呢? 谢谢你!
当我尝试在Android Studio上调试应用程序时,给出了以下日志输出:
APK文件 /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk没有 存在于磁盘上。
我重启了Android Studio,但是我无法解决这个问题。我怎么解决呢? 谢谢你!
当前回答
在gradle 1.5中也遇到了同样的问题
我必须清理构建文件:
Build ->清洁项目
并构建一个APK来强制gradle文件的完整编译和同步:
Build -> Build APK
但我还是不知道为什么会这样。
其他回答
如果你在更新到Android Studio V 3.1后遇到这个问题,那么试试下面的方法。
当我更新到Android Studio 3.1时,我也遇到了同样的问题。我在这里找到的所有其他解决方案都是手动的,因为你每次都必须清理和重建,这一点都不好。但是多亏了Iman Marashi的回答,我才得以解决这个问题。
执行->编辑配置…
确保你有一个Gradle-aware Make在Before launch部分:
要添加它,点击+号,然后选择Gradle-aware Make,一个弹出窗口就会出现,只需要让文本字段为空,然后点击OK和OK。
我的问题是在文件名中包含分钟-它寻找appname_debug_0.9.0.1 1_170214_2216.apk,而生成的文件是appname_debug_0.9.0.1 1_170214_2217.apk,因此输出文件名代码(从其他地方捕获)显然是从构建中的两个不同的点调用的。
applicationVariants.all { variant ->
variant.outputs.each { output ->
def project = "appname"
def SEP = "_"
// def flavor = variant.productFlavors[0].name
def buildType = variant.variantData.variantConfiguration.buildType.name
def version = variant.versionName
def date = new Date();
def formattedDate = date.format('yyMMdd_HHmm')
def newApkName = project + SEP + /*flavor + */ SEP + buildType + SEP + version + SEP + formattedDate + ".apk"
output.outputFile = new File(output.outputFile.parent, newApkName)
}
}
我的问题是我将版本号附加到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)
}
}
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'
}
}
我通过做来解决这个应用
第一次构建- >构建Apk(s) 现在运行应用程序
如果它不工作做清洁和建立项目,然后再做1和2。