Open In App

Different Ways to fix “The APK file does not exist on disk” in Android Studio

Whenever we try to debug the application on Android Studio we encounter the error “The APK file does not exist on disk” in the Android Studio. The MainActivity Page throws the error as:

The APK file /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not exist on disk.



So, In this article, we will discuss 4 different methods for fixing the “The APK file does not exist on disk” error in Android Studio.

Method 1: Click on the Sync button

By clicking on the Sync button on Android Studio, we can easily resolve the error “The APK file does not exist on disk” in the Android Studio version till 3.1.



Method 2: “Gradle-aware Make” on the Before launch section

We are facing this same problem when we updated our Android Studio 3.1 or higher and, clean and fast method to resolve this error, and here, this is the solution:

Method 3: Restart Android Studio

We witnessed this issue also when we switch git branches. So, shutting down Android Studio:

 rm -rfv ~/Library/Caches/AndroidStudio* 

and Restart Android Studio is the solution to resolve this error “The APK file does not exist on disk”.

Method 4: Change the Apk Name 

Usually when project building fails, some common tricks you can try:

But to be more specific to issue- when Android Studio could not find the APK file on disk or in files which means that Android Studio has successfully built the project and generated the APK, but for some reason, Android Studio is not able to find the required file.

In this case, we can check the printed directory according to the log which will be helpful.

For example:

With Android Studio 2.0 Preview (build 143.2443734).

So here you could see, due to Gradle build script’s mistake, file naming is somehow wrong. 

The above scenario is just one example that can lead to this same error, but not necessary to be the same root cause as always. As a result, check your build.gradle script (you may change the apk name there, something like below):

applicationVariants.all { variant ->

       variant.outputs.each { output ->

           def newFileName = “whatever you want to name it”;

           def apk = output.outputFile;

           output.outputFile = new File(apk.parentFile, newFileName);

       }

   }

Article Tags :