Run button isn't compiling project in Android Studio 3.1 [duplicate] - android

When I try to install an app, there are two possibilities:
Install existing APK from build folder when I run the app
Install APK after performing clean build
For existing APK in the build folder, the app just works fine. But when I clean the project using Build -> Clean Project, and then try to run the app (i.e. install the app to my emulator or physical device), it shows me error:
The APK file /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not exist on disk.
NOTE: This behaviour happens only when I clean the project and not when I have already have a pre-built app APK in my build folder
I've referred to: The APK file does not exist on disk but my point is, when we usually run the app after cleaning the project, we never need to make a build of it, if the APK is not existing in the build folder, it automatically generates and installs the latest one.
Things I've tried:
Running the app when APK file exists in the build folder (works perfectly fine)
Running the Clean Project -> Running the app (expected is the project would be built and the app would get installed but it shows the above mentioned error!)
Same process of cleaning and running the app after doing Invalidate Caches/Restart

I have solution for your issue.
Also confirmed by Android Studio on Twitter : https://twitter.com/androidstudio/status/981914632892960768
Edit your app configuration as below.
Here you can see your app configuration as below.
Here is missing Gradle-aware make attribute in before launch configuration. You can see here.
Please add this Gradle-aware Make attribute through this way. Click on + icon and select Gradle-aware Make as seen in this screen.
You can add this without writing any task just press OK button and task will be added and now it should look like this. Now apply changes and run your application.
It will solve this old apk installing issue on clean build in new Android Studio 3.1 issue.
Note : This issue is resolved in new Android Studio 3.1.1 Stable release.

The APK file
/Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not
exist on disk.
May be bug. You should change Settings.
You should open the Run/Debug Configurations dialog & select Run > Edit Configurations
Make sure, Gradle-aware Make is Added in TaskList or not. If not then click + & select from the options.
Note
If you receive
Shutdown finished in 0ms Error while generating dependencies split APK
com.android.ide.common.process.ProcessException: Failed to execute
aapt at
com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:809)
at
com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:797)
at
com.android.build.gradle.internal.transforms.InstantRunSplitApkBuilder.generateSplitApkResourcesAp(InstantRunSplitApkBuilder.java:373)
You should Un-Check INSTANT RUN.
File-- Settings-- Build, Execution, Deployment -- Instant Run and
uncheck Enable Instant Run.

clean your project and run again
If it's not work then
Step 1 Close your project.
Step 2 Go to your project folder and delete all build folder.
Step 3 run your project.

This issue has been fixed with Android studio 3.1.1 (April 2018) release.
Update your android studio to 3.1.1.
Here is there explanation regrading the issue details, cause and solution:
In some cases, when a project created in Android Studio 3.0 was opened for the first time in Android Studio 3.1, the Gradle-aware Make task was removed from the Before launch area in Run/Debug Configurations. The result was that projects did not build when the Run or Debug button was clicked, which in turn caused failures such as deployment of incorrect APKs and crashes when using Instant Run.
To solve this problem, Android Studio 3.1.1 adds the Gradle-aware Make task to the run configuration for projects that are missing this entry. This modification occurs after the first Gradle sync when the project is loaded.
Official release notes: https://developer.android.com/studio/releases/index.html#3-1-0

For all people seing this and having the issue on Android Studio +4.0.0:
Run -> Edit configurations... -> disable check box (Allow parallel run)
It may slow your build a little but it better than running the app more than one time.

Related

Android Studio Fails with: "File was deleted, but previous version not found in cache"

I had a project on Android Studio which was working. But after I ran
git pull and then git reset --hard and tried to run it again, build failed with the message:
File 'com.android.builder.files.ZipCentralDirectory#412e039a' was deleted, but previous version not found in cache
Build -> Clean Project fixed my problem.
Go to Task Manager
Search for any instances of OpenJDK or java in task manager click and End Task
Run flutter clean in IDE
The Reason was Flutter Clean cant delete the build while the Application is still running in the Background process, u have to close it and run.
I also faced the same issue. it occurs when you run> flutter clean command that actually did't clean all the files inside build directory of your project, and causes the issue.
So the simple solution is, delete your build directory manually. If it alerts "File in Use" dialogue then simple do the following steps
open the run command with shortcut Window+R
type resmon.exe it will open the resource monitor
click on "CPU" tab
click on "Associated handles" and type build in search bar
right click on java.exe and end process
restart your IDEA and run your project the problem is solved
An alternative way to fix this issue is to run flutter clean.
You mentioned you are using android studio, go to your terminal inside android studio and then run the above mentioned command.
After the above command was executed then run your app again.
This simple solution worked for me !
Using Android Studio 3.6.2 for a Flutter project there is no 'Build -> Clean' unless you 'Open Android module in Android studio'. Then there is a 'Build -> Clean Project'.
An alternative as mentioned above is to open the terminal in the project where you may Debug your application and run 'flutter clean'.
For me the latter is better since I typically only open the Flutter android module when I want to build a release of my app.
Open Android module in Android studio
run success
execute ‘Build -> Clean’
close Android module in Android studio
run flutter project again

Android Studio 3.1 is not compiling/building the app, runs instantly [duplicate]

When I try to install an app, there are two possibilities:
Install existing APK from build folder when I run the app
Install APK after performing clean build
For existing APK in the build folder, the app just works fine. But when I clean the project using Build -> Clean Project, and then try to run the app (i.e. install the app to my emulator or physical device), it shows me error:
The APK file /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not exist on disk.
NOTE: This behaviour happens only when I clean the project and not when I have already have a pre-built app APK in my build folder
I've referred to: The APK file does not exist on disk but my point is, when we usually run the app after cleaning the project, we never need to make a build of it, if the APK is not existing in the build folder, it automatically generates and installs the latest one.
Things I've tried:
Running the app when APK file exists in the build folder (works perfectly fine)
Running the Clean Project -> Running the app (expected is the project would be built and the app would get installed but it shows the above mentioned error!)
Same process of cleaning and running the app after doing Invalidate Caches/Restart
I have solution for your issue.
Also confirmed by Android Studio on Twitter : https://twitter.com/androidstudio/status/981914632892960768
Edit your app configuration as below.
Here you can see your app configuration as below.
Here is missing Gradle-aware make attribute in before launch configuration. You can see here.
Please add this Gradle-aware Make attribute through this way. Click on + icon and select Gradle-aware Make as seen in this screen.
You can add this without writing any task just press OK button and task will be added and now it should look like this. Now apply changes and run your application.
It will solve this old apk installing issue on clean build in new Android Studio 3.1 issue.
Note : This issue is resolved in new Android Studio 3.1.1 Stable release.
The APK file
/Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not
exist on disk.
May be bug. You should change Settings.
You should open the Run/Debug Configurations dialog & select Run > Edit Configurations
Make sure, Gradle-aware Make is Added in TaskList or not. If not then click + & select from the options.
Note
If you receive
Shutdown finished in 0ms Error while generating dependencies split APK
com.android.ide.common.process.ProcessException: Failed to execute
aapt at
com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:809)
at
com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:797)
at
com.android.build.gradle.internal.transforms.InstantRunSplitApkBuilder.generateSplitApkResourcesAp(InstantRunSplitApkBuilder.java:373)
You should Un-Check INSTANT RUN.
File-- Settings-- Build, Execution, Deployment -- Instant Run and
uncheck Enable Instant Run.
clean your project and run again
If it's not work then
Step 1 Close your project.
Step 2 Go to your project folder and delete all build folder.
Step 3 run your project.
This issue has been fixed with Android studio 3.1.1 (April 2018) release.
Update your android studio to 3.1.1.
Here is there explanation regrading the issue details, cause and solution:
In some cases, when a project created in Android Studio 3.0 was opened for the first time in Android Studio 3.1, the Gradle-aware Make task was removed from the Before launch area in Run/Debug Configurations. The result was that projects did not build when the Run or Debug button was clicked, which in turn caused failures such as deployment of incorrect APKs and crashes when using Instant Run.
To solve this problem, Android Studio 3.1.1 adds the Gradle-aware Make task to the run configuration for projects that are missing this entry. This modification occurs after the first Gradle sync when the project is loaded.
Official release notes: https://developer.android.com/studio/releases/index.html#3-1-0
For all people seing this and having the issue on Android Studio +4.0.0:
Run -> Edit configurations... -> disable check box (Allow parallel run)
It may slow your build a little but it better than running the app more than one time.

Installation failed with message Invalid File

Installation failed with message Invalid File:
K:\project\app\build\intermediates\split-apk\with_ImageProcessor\debug\slices\slice_0.apk.
It is possible that this issue is resolved by uninstalling an existing
version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
i am running my project in android studio 2.3 beta 3 .
Click Build tab ---> Clean Project
Click Build tab ---> Build APK
Run.
I found the solution go to
settings>build,execute,deployment>instant run>Enable instant run to
hot swap code /resource change on deploy(unchecked this option)
`
Just follow two steps
Step 1 : Build---> Clean
Step 2 : Build--> Build APK
Hope it works. Good luck guys
I solved it this way:
Click Build tab ---> Clean Project
Click Build tab ---> Rebuild Project
Click Build tab ---> Build APK
Run.
Hopefully, this should solve your problem.
Do follow the following steps.
1. Clean your Project
2. Rebuild your project
3. Finally Build and Run your project
First, as already mentioned, try cleaning and rebuilding the project. If that does not work for you, try this:
Settings > Build, Execution, Deployment:
Un-check Enable Instant Run to hot swap code...
This solved the problem right away for me.
P.S. I posted this answer since it's 2017 and I don't think this feature existed in 2014, so it wouldn't cause this problem.
Please follow the below steps
File > Settings > Build,Execution,Deployment > Instant Run > Un-check (Enable Instant Run to hot swap code)
this is working for me
thanks
This happened with me when I copied a project code from one laptop to another one and tried running the project. What fixed this for me was:
Delete the project's build folder
Clean Project
Build project
Run
In my case, I had the same issue when the name of my project contains a "&" sign.The solution is to rename the project name,from file browser, so it doesn't contain any "&" signs and then from:
Build menu-> Clean Project
Build menu-> Build APK
I've tested it two times and it worked just fine.
For me it's:
Click Build tab --->
Clean Project
Rebuild Project
Build APK
follow some steps:
Clean Project
Rebuild Project
Invalidate Caches / Restart
Now run your project. Hope it will work.
It's work for me.
Work for me:
Delete these folders
Run app
Try this in gradle project
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3' }
Delete the Intermediate folder after then run the project is working fine actually that APK builds to another system.
Go to app/build/intermediates.
In my case , there was a single qutation ' in project directory and after removing it resolved
I found its work by restarting my phone :)
Invalidate cache/restart
Clean Project
Rebuild Project
Run your app / Build APK
These steps are enough to solve most of the problems related to Gradle build in any way. These steps helped me solve this problem too.
Try cleaning the project and rebuild, if doesn't work try disabling the Instant Run from Settings>Build>Instant Run in case you are running someone else's code.
My issue was with my Android Studio install.
I am building out a new CI server and although I installed Android Studio and hooked up the SDK, etc., I did not open the studio with the project -- instead just went to the command line to build. When I subsequently opened the project in the studio, it started prompting for all sorts of updates. Followed the bouncing-ball and then I was able to reach my USB tethered device.
Hopefully, this is helpful for Build Master and DevOps as a "got-cha" to avoid.
None of the answers here worked, I had to:
Close android studio
rm -rf ./android/.idea
Build -> Build Bundle/APK(s) -> Build APK(s)
The path may be invalid, if Android Studio is pointing to the wrong version of the file. This can happen if you make gradle automatically rename your built APK, using setProperty(), like:
defaultConfig {
applicationId "com.company.app"
versionName "1.2.0"
// Rename the built apk file
setProperty("archivesBaseName", "MyApp-$versionName")
...
}
Sometimes, an updated versionName is not properly "refreshed" to Android Studio, so it can point to an old versionName in the file name. In this case, just do a Gradle sync then Build, to ensure the versionName matches the built file path. Gradle sync is either:
Android Studio 4.x ➔ Toolbar at the far right ➔ Press the 'elephant + down arrow' icon, which has the tooltip "Sync Project with Gradle Files" ➔ Build ➔ Make Project
Android Studio 4.x ➔ Help ➔ Find Action ➔ search for "sync" ➔ "Sync Project with Gradle Files" ➔ Build ➔ Make Project
If none of those solutions work for you just close the Android Studio and open it. It worked for me on Mac.
Just Invalidate Cache and Restart !!! 🙌🏻

Android Studio - Can't Disable Instant Run

I have a LibGDX project which is made up of a core project and multiple Android/desktop projects which are dependent upon it.
I'm currently changing some code in the core project but upon manually building, cleaning, and running the changes are not being reflected when I run the project.
From my searching I feel the issue is related to Instant Run, but I cannot disable it as the checkboxes are grayed out.
Is my issue related to Instant Run? And how would I go about disabling it?
it seems you need a successful build with gradle (at least up to the configuration phase) and then the checkbox gets editable.
On a new installation of Android Studio 3.0.1, I found that I couldn't build a project because of Instant Run and that the Enable Instant Run was forced on and greyed out so that it couldn't be disabled.
The build error was:
Error:Failed to notify project evaluation listener.
I found that doing a build from the command line fixed both the failure to build and not being able to disable Instant Run.
./gradlew assembleDebug
Make sure you change the Instant Run setting in a specific project.
I mean you need to do:
Open the specific project
Right click on the file
choose settings
Build
Instant run
For me its work

Android Studio 0.5.3 - Why doesn't "Make Project" run build any more?

"Make Project" in Android Studio doesn't build an apk file for me since I upgraded to 0.5.3. Does anyone know how I can make it do so?
I have updated buildToolsVersion to 19.0.3, which is the latest version.
(Every time Android Studio updates it creates another problem like this, I'm sorry but I'm not an expert on build systems, I scarcely even have any idea what kind of voodoo is involved in building a project).
Thanks.
You need to now run an assemble gradle task to make the apk. Here is a post on Google+ in "Android Developer Tools" community on the subject (By Alex Ruiz).
"Build > Make" behavior changes.
In the next version of Android Studio (0.5.3,) we have changed the behavior of the "Build > "Make" menus. Instead of invoking "assemble" Gradle tasks, now they only compile Java code (generating R.java if necessary,) similar to Eclipse ADT's behavior. This change will speed up development workflows (pre-dex, dex, packaging, etc. will be executed only when running/debugging an app or when exporting an APK.)
As a side effect the menu "Build > Compile" has been removed, since it is now redundant.
The "Make" button in Android Studio now runs the gradle android plugin task "compileDebugJava". In order to build the APK file, it needs to run the task "assembleDebug". I'm not sure what the rationale was for changing the behaviour of the button, or how to change it back. The only easy way (i.e. not using the command line) to get the assembleDebug task to run is to have a run configuration which runs a "Gradle-aware Make" before launch. The "gradle-aware Make" is simply the assembleDebug task.
I preferred the old behaviour, but of course, Google knows best.
Edit: I know nobody cares, but I worked around this by adding gradlew to Android Studio as an external tool, with the command line option "assembleDebug" and then adding a custom button to the toolbar to run this external tool. I now use this button instead of the Make Project button as it does what I would like to do (build an APK).
Here is a simple way to build the APK file:
Open the Gradle Tool window. To find that window, use Help->Find Action, type "Gradle" and select "Gradle" in the "Tool Windows" category;
Double-click "assembleDebug" to build the APK.
Or better: right-click "assembleDebug" and choose "Create...", so that this task will be saved for future usage in the configurations menu that appear on the main toolbar.

Categories

Resources