Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The .apk file does not exist on disk but it does

Whenever I debug application, error appears that ... .apk file does not exist on a disk and app doesn't launch.

After updating Android Studio, this error started happening.

I tried different solutions after a lot of searching. This includes:

  1. Downgrading Android Studio (it starts giving plugins error and I don't want not to be able to use new Android Studio)
  2. Tried this solution with no luck.
  3. This catering different problem but with possible solution of my problem. It didn't work too.
  4. Referred to the issue

Any help will be appreciated.

like image 438
Waqas Ahmed Ansari Avatar asked Sep 29 '16 08:09

Waqas Ahmed Ansari


2 Answers

If you have something like this in your build.gradle file:

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

And this

def getDate() {
    def date = new Date()
    def formattedDate = date.format('dd.MM.yyyy')
    return formattedDate
}

You should remove getDate() from output to fix your problem. Take a look at this post also.

like image 145
Andrey Mohyla Avatar answered Oct 04 '22 00:10

Andrey Mohyla


Check your path to your apk. Might there be some special characters in folder names. This also cause the adb to through this error.

like image 44
SAIR Avatar answered Oct 03 '22 23:10

SAIR