当我尝试在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,但是我无法解决这个问题。我怎么解决呢? 谢谢你!
当前回答
我的问题是我将版本号附加到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)
}
}
其他回答
当我切换git分支时,我经常看到类似的问题。对我来说,关闭AndroidStudio rm -rfv ~/Library/Caches/AndroidStudio*并重新启动AndroidStudio是门票。
构建APK(s),并确保它工作
确保在路径中没有撇号或&
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'
}
}
对于Unix类用户(Linux/MacOs X),而不是删除~/。Gradle /caches/,在命令行执行:
$ cd path_to_you_project
$ touch build.gradle
然后要求Android Studio构建APK,它将重置gradle缓存本身。