By sorunluadam


2015-12-02 10:02:27 8 Comments

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

30 comments

@Jenkyn 2019-07-15 03:14:31

in my case, just

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

@MiguelSlv 2019-02-03 18:02:08

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.

@Juan Ignacio Barisich 2019-07-19 15:18:55

Then you need to click on File / Re-Import Gradle project. This will recreate the deleted run configuration.

@Christian Schulzendorff 2018-10-15 13:24:08

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

@指尖上的Android 2016-01-08 02:47:05

Click this option to solve the error:

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

@N.P 2016-10-20 06:25:24

Special characters in your project directory name will also throw this error.

@person27 2017-10-27 18:22:21

This didn't work for me at all. I would advise answers that explain why they are supposed to work rather than just telling the reader what to do, so that they can understand / avoid / solve those errors later.

@Hamidreza Sahraei 2017-11-18 10:30:12

Would you explain what does this exactly do and why this problem happened?

@alexr101 2018-07-06 04:34:33

btw "Special characters" also include numbers. It's ridiculous, wasted tons of time on this. facepalm :)

@tsaulic 2018-08-23 00:43:14

Funny, for me it did not work for some reason in Android Studio 3.1.4, at least not until I actually restarted the IDE.

@nasch 2019-02-08 02:48:09

That button doesn't exist on the latest version of Android Studio, but I believe it's the "Sync Project With Gradle Files" option, which did work for me.

@Jay Smoke 2019-04-03 23:50:34

I assume this is an old version, but clicking sync with gradle didn't work for me. Adding Gradle-aware Make to Debug Configuration as stated by @Seven did the trick.

@BISHWAJEET 2018-08-03 07:34:54

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.

@live-love 2018-03-19 19:46:20

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.

@Napolean 2018-04-17 11:12:57

In Studio v3.1.1 , File -> Sync Project with Gradle Files. and you are good to go

@CodeToLife 2019-02-15 20:35:05

Then in a field on top toolbar(with icones), in next from hammer icon you have to return 'app ' back, in configuration dropdown

@Rob Breidecker 2018-04-05 11:39:45

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.

@Seven 2018-03-28 02:02:44

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.

@David Gay 2018-03-29 14:54:33

This is the fix for the recent 3.1 update. For me, the first symptom of this issue was the APK not "responding" to changes in the code. It's now clear to me that the new APK wasn't building properly at all.

@ZarNi Myo Sett Win 2018-03-30 03:40:13

This answer can solve for me. I updated 3.1 and get this error.

@Robert Goodrick 2018-03-30 03:43:54

This should be the the accepted answer

@Swapnil 2018-04-04 14:29:48

Everytime update introduces a new issue.

@coder 2018-04-05 13:11:27

Wow. Wish I could upvote 100 times

@Joel Libby 2018-07-16 23:18:03

You sire are a life saver.

@1QuickQuestion 2018-07-20 18:31:44

WOW! You deserve 1000 up votes for this! Android Studio deserves 1000 down votes!

@Petar Marijanovic 2019-03-01 13:24:34

Thanks, this is definitely the right answer and should be the accepted one

@Rockin4Life33 2019-03-24 20:50:02

This helped resolve my issue where I have my build.gradle changing the name of the APK that is kicked out based on the variant, versionCode, & versionName.

@lior_13 2019-03-26 11:36:52

I faced the problem after Android Studio froze and been killed while building a release APK and that answer solved the problem

@Tzegenos 2019-05-14 09:52:02

You are a professor. / Είσαι καθηγητής.

@Gerardo Suarez 2018-04-02 17:28:35

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.

@Androiderson 2018-02-19 19:02:32

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

@behelit 2018-03-23 02:55:38

but this only works for one build? if you make further changes and press the 'play' button, it just pushes the old apk and doesn't rebuild for the changes. So annoying, wtf were they thinking

@Boldijar Paul 2018-03-29 08:18:38

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.

@Sai Gopi N 2018-03-28 11:13:38

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.

@Seven 2018-03-28 15:47:32

That works but is very inconvenient as you have to do that process every time you want to run your app. If you are having that problem after a Android Studio update take a look at my answer on this thread...

@Kadir altınok 2018-03-28 09:42:00

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

@Viren Mody 2018-03-28 02:07:45

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.

@priti 2018-01-31 12:52:24

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

@Lee Brindley 2018-01-10 16:23:31

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

@Iman Marashi 2017-11-27 18:09:41

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

Like this image

@Sonu Kumar 2017-10-20 06:35:25

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

@Martin Zeitler 2017-07-14 10:26:52

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.

@兰坡阳 2017-02-22 07:32:19

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.

@Ian Spencer 2017-02-14 22:44:22

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

@Nerius Jok 2018-05-06 09:49:31

where is this block from?

@Ian Spencer 2018-05-07 15:08:50

It was from some other stack exchange thread from when I was first setting up the project (and had very little idea what I was doing - nothing changed there). As this part of Gradle has been changed a few times it is likely obsolete code now.

@Dmytro Karataiev 2017-01-16 09:41:01

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.

@u_pendra 2016-12-07 05:55:03

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

@Rim Gazzah 2016-11-16 14:39:40

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

@Marka A 2017-10-14 11:16:16

The '&' was what was keeping me from compiling. Thanks @Rim Gazzeh

@AnZ 2016-11-14 13:17:10

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

@Immortal Code 2016-10-10 23:57:44

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.

@Immortal Code 2016-11-02 16:12:20

Yeah ideally Android Studio should be smart enough to prevent users from using special character in their file path. Or better I should have followed the good programming practices myself :)

@Orientos 2016-10-04 11:58:44

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.

@Amgad 2016-08-30 09:00:30

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.

@dvrm 2016-07-28 10:53:46

File -> Invalidate Caches / Restart

@Lou Morda 2016-05-17 22:56:52

My problem is that I was appending the version number to the APK. Changing the version number and re-syncing Gradle fixed the problem for me.

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

@Dhrupal 2016-07-01 12:43:26

Have you called appendVersionNameVersionCode in gradle itself?

Related Questions

Sponsored Content

11 Answered Questions

[SOLVED] Install an apk file from command prompt?

  • 2011-08-16 09:38:32
  • Max
  • 504621 View
  • 394 Score
  • 11 Answer
  • Tags:   android cmd apk

19 Answered Questions

[SOLVED] Unfortunately MyApp has stopped. How can I solve this?

38 Answered Questions

[SOLVED] Is quitting an application frowned upon?

  • 2010-01-09 15:59:46
  • Ted
  • 270434 View
  • 1129 Score
  • 38 Answer
  • Tags:   android

21 Answered Questions

[SOLVED] Is there a way to get the source code from an APK file?

33 Answered Questions

[SOLVED] How to avoid reverse engineering of an APK file?

34 Answered Questions

[SOLVED] Android Studio: Add jar as library?

27 Answered Questions

8 Answered Questions

[SOLVED] Android error: Failed to install *.apk on device *: timeout

2 Answered Questions

[SOLVED] Difference between app-debug.apk and app-debug-unaligned.apk

Sponsored Content