Exactly my problem, if I have small change in app about display UI (modify activity code or resource layout), Android studio build very fast and then run my app in emulator without kill "previous version" process (running in emulator), sometime it's run and display correct, but sometime it doesn't run correct what I want, I must kill process manual and rebuild project, it takes a lot of time, and makes me confused because I don't know where go wrong,
I thought this is my bug.
It happen recently when I update Android studio, I think this feature is very powerful and helpful, application mustn't rerun from the beginning whenever build new version.
But how to enabled/disabled "fast build", sometime I want Android studio build my project normally.
You have 2 solution:
1)You can also disable Instant Run from Settings > Build,Execution,Deployment > Instant Run - and disable it
2)Clean Project when studio doesn't build properly
Press the stop button before running the app and then run the app so dialog will be displayed to choose the emulator.
Related
I saw a similar question but none of the answers actually tell you how to disable it, just give workarounds for the issue. I want to totally disable instant run, how can I do that?
The issue I have is that no matter what I do, use the run button, the debug button, the apply changes button, clean, etc, any code I just wrote won't run until I uninstall the app on the phone, if I don't do that all I see is the old code running. I'm guessing instant run is the issue since I always get the message that says App restart successful without requiring re-install.
From android studio 3.5 and above you cant disable it but if your running an earlier version: Go to Android Studio Settings or Preferences (for MAC) -> Build,Execution,Deployment -> Instant Run. Then deselect the "Enable Instant Run" checkbox at the top.
Last night, I clicked "run" button and Android Studio built my app.
But after completing the build task, it did not work on my device anymore.
How to fix that? Do I have to set the auto run option?
I checked the application installation on my device.
My issue is that "autorun on device" does not work.
Open the Gradle tab that is on the right side of the Android Studio UI.
Find the installDebug option, and the Run button will use that as the "last ran" command.
If you are otherwise unable to run the app, then you may have a compilation issue
At this point, Im using Android Studio 2.1.2. When I changed the code or without changed the code, the app is always kill and restart the session when I want to run the app.
Run App
So how to run the app without kill and restart the session?
You are wondering about Instant Run facility added in most latest versions of android studio. To use it please Make sure you have up to date Gradle plug-ins and builds because it's not only enough that having latest version of Android studio will support Instant Run it also required all stuff up-to-date so Please first check it out.
To check it out if it is disable follow this steps
1) Go to File -> Settings
2) Go to Build,Execution,Deployment -> Instant Run
By default It is enabled if everything is up to date. If not you can.
Go read this for depth understanding : https://medium.com/google-developers/instant-run-how-does-it-work-294a1633367f#.mqwx46kn6
And what is supported under instant run is given here.
https://stackoverflow.com/a/33905037/5476209
You need the latest Gradle build in your project for the same And also you need to run the same app in your phone so that the patch will be installed and activity will be restarted.
Please not that every time you hit an error in run time the quick launch will get disabled and you will have to rebuild the whole project to Instant run again.
Reference :http://tools.android.com/tech-docs/instant-run
I tried to run app from Android studio, and it worked. But after stopping and starting few times this message appears.
Uninstalling and installing over again works, but as soon I restart the program the same message reappears.
"Your app does not have the latest code changes because it was restarted manually. Please run from IDE instead."
I am running everything from IDE. Nothing it done through the phone itself.
For me even killing the app and running from Android Studio still appeared the same sentence "Your app does not have the latest.."
What always works is Run > Computer > Clean and Rerun 'app'
You saw this message because you killed and restarted your app manually after "Instant Run" applied changes to your app.
In Android Studio 2.0, a new feature was added called "Instant Run".
Instant Run is described in the Android Studio Project Suite:
Introduced in Android Studio 2.0, Instant Run is a behavior for the Run and Debug commands that significantly reduces the time between updates to your app. Instant Run pushes changes to methods and existing app resources without building a new APK, so code changes are visible almost instantly.
A demo of Instant Run can be seen in this video.
If you make a small change or changes, those changes will be implemented via Instant Run. However, since it did not build a new APK, killing that running instance of your app will discard those changes from the app installed on your device.
From the Developer site:
Note: If you need to restart your app after a crash, do not launch it from your target device. Restarting your app from your target device does not apply any of your code changes since the last cold swap or incremental build. To launch your app with all your recent changes, click Run (or Debug ) from Android Studio.
To have the changes permanently implemented to your app, kill it (actually make sure it gets killed, don't just hit the home button), and then build and run it again from Android Studio.
well if that message appears you don't need to uninstall the app
Just press the red button highlighted in the pic
it will stop your app and then if you run it again then it will run fine with latest code.
NOTE: you can press red stop button only if the app is running and your device is connected to the android studio, it will kill the app process and when you re-run it it will have the latest changes.
if this doesn't solve your problem then you can go to Run>Clean & Re-Run.
Hope it helps
Use Rerun
When pushing code changes that affect certain initializers, such as changes to an app's onCreate() method, you need to restart your app for the changes to take effect. To perform an incremental build and restart the app, click Rerun .
If you need to deploy a clean build, select Run > Clean and Rerun 'app' from the main menu, or hold down the Shift key while clicking Rerun . This action stops the running app, performs a full clean build, and deploys the new APK to your target device.
I tested the way of Shifting key while clicking Rerun, it works fine.
Link : https://developer.android.com/studio/run/index.html
I download the latest Android Studio 2.0 from Android Develop Website.
But when I change a line of code and use the "instant run", instead of updating the changes, it prompt me "no changes to deploy".
This will happen on code changes and XML changes.
But when I restart Android Studio, things will works fine for once or twice and then "no changes to deploy" Come again!
I used my old SDK on Android Studio older version.
JDK is 1.7.0
Windows7 64
So, is anyone has this same bug?
A lot of people are having this issue as Instant Run is still quite buggy. The best thing to do would be to disable Instant Run entirely by Preferences > Build, Execution, Deployment > Instant Run > Enable Instant Run
Solved by rebuilding Project (menu Build -> Rebuild project)
This sounds like a bug. It would be super helpful to our team if you can report the bug with specific repro steps so we can investigate. Without your help, it's going to be very difficult for us to track down these problems. We want Instant Run to work for you.
You can file a bug at this link: https://code.google.com/p/android/issues/entry?template=Android%20Studio%20Instant%20Run%20Bug
Also having this issue with Android Studio 2.1. Turning off Instant Run seems to have fixed it, which is unfortunate, but I was wasting more time failing to understand why old code was being run than Instant Run was saving me! Running Ubuntu, so agree not just a Windows bug.
Run TAB next to anroid-monitor, sometimes it shows, no changes to deploy mean changes in code has not been added to your app(this bug has been resolved to a great extent).
Sometimes it runs the new app and when you restart your app it shows the old one(this bug has been resolved, officially declared on android site ).
Solution :
Disable instant run under your project settings(you can face some error while gradle build if you switch from instant-Run to normal one then Try clean option or if still there's an error then you can delete those files at the path shown by the error)
Try to use the latest studio release which has totally improved
instant-run.
Not a solution but as a better workaround I'd prefer to:
Press "Recent Apps"
Simply close my app from the list
Run the app again
This takes less time than Clean and Rebuild.
Update:
Rerun the app also works:
When Instant Run does not works correctly:
As far as I realized, Instant Run works properly when I change my views ids otherwise it does't recognise changes in xml and gives me "No changes to deploy"
I also used clean and rerun app or Cntrl+F5 this fix my problem