yusufonderd
yusufonderd

Reputation: 3247

The APK file does not exist on disk

When I am trying debug application on Android Studio gives this log output :

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

I restarted Android Studio, but I can't solve this problem . How can I solve it ? Thank you

Upvotes: 230

Views: 128468

Answers (30)

GiridharaSPK
GiridharaSPK

Reputation: 547

Sync, Clean, Rebuild and Invalidate Cache and Restart

None of them worked for me.

I have deleted the APK and output.json files in the release folder and debug folder and then tried sync, clean, and build, then it worked fine.

OR simply Delete folder which has the apk and output.json file (in case of debug/ release)

Upvotes: 2

Braian Coronel
Braian Coronel

Reputation: 22867

assemble[Variant] would generate the APK for you on disk although it should not be necessary to use it to debug the app.

Run the following command in the root directory of the project:

$ ./gradlew clean build assemble[Variant]

GL

Upvotes: 0

Jenkyn
Jenkyn

Reputation: 339

in my case, just

View > Tool Windows > Gradle > right click [project] > Refresh Gradle Project

Upvotes: 0

MiguelSlv
MiguelSlv

Reputation: 15113

In my case the problem was that debugging configuration become invalid somehow, even that the test method name, class or package has not changed.

I deleted the configurations from Run->Edit Configurations, at here:

enter image description here

Android studio will create a new one automatically.

Upvotes: 2

Christian Schulzendorff
Christian Schulzendorff

Reputation: 1471

Solved this issue by updating the Android SDK-Build Tools.

Upvotes: 0

指尖上的Android
指尖上的Android

Reputation: 4798

Click this option to solve the error:

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

Upvotes: 465

BISHWAJEET
BISHWAJEET

Reputation: 61

Go to Build option on the top bar of android studio>create 'Build APK(s)', once build has created, open the folder where it has available(app\build\outputs\apk) then close the folder, that's all....then try to install the app.

Upvotes: 0

live-love
live-love

Reputation: 52366

In Android Studio 3.1.1 select File | Sync Project with Gradle Files.

In Android Studio 3, select File | Synchronize.

Then run your project again.

Upvotes: 13

Rob Breidecker
Rob Breidecker

Reputation: 604

I tried all of these things and none of them worked. I ended up having to do a couple of these things are the same time. Very frustrating that it took this much time.

The problem I had was related to running my unit tests following the upgrade to AS 3.1.

Here is what I did... 1.) Run / Edit Configurations / Select Tests.... 2.) Add options to "Gradle-aware Make" 3.) Select check box "Skip installation if ADK has not changed" on Misc tab

Good luck.

Upvotes: 0

Seven
Seven

Reputation: 3252

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.

Upvotes: 210

Gerardo Suarez
Gerardo Suarez

Reputation: 362

Solved in may of 2018 with the new Android Studio 3.1. Delete the .gradle, .idea and build directories inside your app folder. Then try to run it again and you won't see the error.

Upvotes: 1

Androiderson
Androiderson

Reputation: 17083

The year is 2018. Android Studio version is 3.2.0 alpha3 and we still get this problem. As none of the above worked for me, here is my 2 cents:

Every time this happens I just generate the apk from command line:

gradlew assembleDebug

UPDATE

Deleting the folder .AndroidStudio[version] and losing all your preferences and caches... seems to solve the problem

Upvotes: 12

Boldijar Paul
Boldijar Paul

Reputation: 5495

The problem for me was that somehow it could really not find the apk, while the apk exists.

The APK file /Users/Paul/AndroidStudioProjects/android-tv-launcher/ui/build/outputs/apk/nameofapk.apk does not exist on disk.
Error while Installing APK

All I had to do, was right click on the apk-copy relative path, and just

adb install -r <paste of relative path>

And the apk was installed and good to go. This issue happened on OSX for me.

Upvotes: 1

saigopi.me
saigopi.me

Reputation: 14908

i solved this app by doing

  1. First Build - > Build Apk(s)
  2. Run the app now

if it not worked do Clean and build the project and then do again 1 & 2.

Upvotes: 0

Kadir altınok
Kadir altınok

Reputation: 230

Build ---> Build APK(s) and be sure it works

Upvotes: 3

Viren Mody
Viren Mody

Reputation: 11

I got it to work by:

  1. Closing the project
  2. From the Android Studio Welcome Window (or File > New), click on Import Project.

I guess that forced it to reinstall the APK, and now everything is running fine.

Upvotes: 0

priti
priti

Reputation: 912

    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'
            }
        }

Upvotes: 0

Lee Brindley
Lee Brindley

Reputation: 6472

Using Android Studio 2.2.1, I clicked the Sync Project with Gradle Files option, from the dropdown at the top, Tools>Android

Similar, to an answer posted above, see below for a screenshot of how to get to this option.

enter image description here

Upvotes: 0

Iman Marashi
Iman Marashi

Reputation: 5753

Make sure that there is Grading-aware Make in Run/Debugging configurations >> before launch section :

Like this image

Upvotes: 19

Sonu Kumar
Sonu Kumar

Reputation: 91

First remove cleaner by going to edit configuration, It may be cleaning the build after building the apk.

Click on edit from set run/debug then click on gradle list select the clean project item and then click on -(top 2nd from left).

Upvotes: 0

Martin Zeitler
Martin Zeitler

Reputation: 76579

The button is called "Sync Project with Gradle Files" and it looks alike: Gradle Sync... always need to click it, when updating the version number, which is resulting in another APK filename (unless the filename has not changed, installing the package always works, which hints for, that the filename is being cached). The equivalent Gradle CLI option appears to be --recompile-scripts.

@see Appendix D. Gradle Command Line.

Upvotes: 0

兰坡阳
兰坡阳

Reputation: 151

modify the file:build.gradle(app directory). in fact:you should not change this file , only by this to get sync tips,then sync project.

Upvotes: 0

Ian Spencer
Ian Spencer

Reputation: 566

My problem was including minutes in the file name - it looked for appname_debug_0.9.0.1_170214_2216.apk when the generated file was appname_debug_0.9.0.1_170214_2217.apk so the output filename code (nabbed from elsewhere) was clearly being called from two different points in the build.

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)
        }
    }

Upvotes: 1

Dmytro Karataiev
Dmytro Karataiev

Reputation: 1304

Nothing above helped me, but I figured this out by switching to another flavor in the Build Tools panel and then switching back to the needed one.

Upvotes: 0

u_pendra
u_pendra

Reputation: 948

I also got that issue, after cleaning the build. For me solution was I just sync the gradle and it worked for me.

Upvotes: 2

Rim Gazzah
Rim Gazzah

Reputation: 571

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

Upvotes: 20

AnZ
AnZ

Reputation: 1060

If you tried all the above answers and it didn't work try to disable "Instant Run" feature. This one helped me after all attempts.

File -> Settings -> Build, Execution, Deployment -> Instant Run -> Uncheck checkbox there

Upvotes: 2

Immortal Code
Immortal Code

Reputation: 101

In my case, I was using a special character in my app file path. I closed the Android Studio and removed the ' character from my app file path. Everything worked fine when I reopned the project.

Upvotes: 7

Orientos
Orientos

Reputation: 151

i had the same problem. it was due to false name in the path. there was a special Character in the path like this: C:\User\My App\Projekte-Tablet&Handy i deleted the "&" character and it worked well.

Upvotes: 1

Amgad
Amgad

Reputation: 169

Make sure that in the path generated in your logs -in your case:

/Users/MyApplicationName/app/build/outputs/apk/app-debug.apk

folder "outputs" indeed has an "apk" folder.

That was my problem, if it's not there, you will need to run the "assembleRelease" task in gradle by following the below screenshot;

Steps to run the gradle assembleRelease task Then the folder will be generated.

Upvotes: 0

Related Questions