Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The APK file does not exist on disk

People also ask

Where are my APK files stored?

If you want to locate the APK files in your Android phones, you can find the APK for user-installed apps under /data/app/directory while the preinstalled ones are located in /system/app folder and you can access them by using ES File Explorer.


Click this option to solve the error:

Run: View > Tool Windows > Gradle > [project] > Tasks > build > build


If you are facing this issue after the update to Android Studio V 3.1 then try the below.

I was facing this same problem when I updated to Android Studio 3.1. All other solutions I found here were quite manual because you have to clean and rebuild every time, that is not good at all. But thanks to Iman Marashi's answer here I was able to solve it.

Go to Run -> Edit Configurations...

Make sure you have a "Gradle-aware Make" on the Before launch section:

Run/Debug Configurations

To add it click the + sign and select Gradle-aware Make and a popup will appear, just leave the text field empty and click OK and OK.


In my case, executing "Sync Project with Gradle Files" helped. Neither restarting Andoid Studio nor clearing the cache did anything.


If you just want to know the conclusion, please go to the last section. Thanks.

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

  • Build -> Clean Project
  • Check Build Variants
  • Restart Android Studio (as you mentioned)

But to be more specific to your problem - when Android Studio could not find the APK file on disk. It means that Android Studio has actually successfully built the project, and also generated the APK, however, for some reason, Android Studio is not able to find the file.

In this case, please check the printed directory according to the log. It's helpful.

For example:

With Android Studio 2.0 Preview (build 143.2443734).

  1. Checkout to a specific commit (so that it's detached from head): git checkout [commit_hash]
  2. Run project
  3. Android Studio tells: The APK file /Users/MyApplicationName/app/build/outputs/apk/app-debug-HEAD.apk does not exist on disk
  4. Go to the directory, there is a file actually named: app-debug-(HEAD.apk (with an extra parenthesis)
  5. Run git branch

    *(HEAD detached at 1a2bfff)

So here you could see, due to my gradle build script's mistake, file naming is somehow wrong.

Above example is just one scenario which could lead to the same issue, but not necessary to be the same root cause as yours.

As a result, I strongly recommend you to check the directory (to find the difference), and 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);
        }
    }

Make sure that you don't have apostrophe or & in your path