run app vs apply changes android studio 2.3 - android

What is the major difference between
Run app and Apply changes?
What could be the best scenario to use each?
Thanks.

"Apply changes" will be enabled if you have "instant run" enabled and to disable instant run check https://stackoverflow.com/a/35169716/2826147
From the Android documentation: https://developer.android.com/studio/run/index.html
Apply Changes button provides a faster workflow for most incremental changes to your app. [...]
You can clickApply Changes to push certain code and resource changes to your
running app without building a new APKā€”and, in some cases, without
even restarting the current activity. [...]
Clicking Run (or Debug ) forces a cold swap and an app restart.
If you make a change to the app manifest or a resource referenced by
the manifest, Android Studio always pushes your changes with a full
APK reinstall. [...]
Apply Changes action is available only when you meet the following conditions:
Build your app using a debug build variant.
Use Android plugin for Gradle version 2.3.0 or higher.
Set minSdkVersion to 15 or higher in your app's module-level
build.gradle file.
Deploy your app to a target device running Android 5.0 (API level 21)
and higher.

When you click "Run" App icon, it will uninstall existing build and install build every time.
"Apply Changes" option will be available only if you enable "Instant Run" feature in android studio. It will swap changes to existing build and run your build. Your existing build will not get uninstalled when you do this.

The Instant Run / Apply Changes feature will try to push your changes without building and deploying a full APK, and if possible without restarting the application or even the current activity. It will resort to a full reinstall if needed. More details here.
Before Android Studio 2.3, the Instant Run feature was available through the Run (or Debug) button, as long as certain conditions were met. Starting with Studio 2.3 we have a dedicated button for Instant Run, which is the Apply Changes button. It is only available when Instant Run is possible. The Run and Debug button now always restart the app.
From the Release Notes:
A separate button to push changes with Instant Run: After deploying your app, you now click Apply Changes to quickly push incremental changes to your running app using Instant Run. The Run and Debug buttons are always available to you when you want to reliably push your changes and force an app restart

for Android Studio 3.5 and higher

Related

How to disable Instant Run in Android Studio 4.0?

I updated to the new Android Studio version 4.0 and there's an irritating issue I am facing which
I believe is a result of instant run (or whatever the new name of this feature is). Basically on using the Android studio run/play button, the app does not launch on the device sometimes and erratically. It always installs but sometimes fails to launch.
I have had similar issues in the past and simply disabled instant run, however, in Android Studio 4.0 I can't see any option anywhere to disable it. I read somewhere that the feature name is changed but searching for that name also didn't yield any results.
How can I disable instant run in android studio 4.0?
I've faced the same issue and disabling parallel run option in the edit configuration window solved the issue for me.
"Apply Changes" has been introduced in replacement of instant run. Besides the Run green button in Android studio, there is apply change option in android studio 4.

android studio requires different app Building and Runing

Recently I have updated my android studio v3.0 to v3.1.
in v3.0 when I click on Run button. It automatically complies builds apk and installs app on my phone.
But at newer version I have ti rebuild app each time before running application. Otherwise it installs previous compiled APK on my phone. Is their a way to do both at on button click.
because its frustrating.
I have searched in settings but no option found.
I had the same problem. I fixed the problem provisionally, adding the task 'app: clean' in the Run / Debug Configuratrions before the app is "made". It takes much longer to compile and build the app than before, but it will always install the latest version, at least for me.
Open the Run / Debug Configurations. Can be found to the left of the Run Button.
Run / Debug Configurations
In the configurations you will find at the bottom the section "Before launch". There, you are leaving out "Run Gradle Task".
Adding Run Gradle Task
Under Project you choose your current project and at Task you choose clean.
Select settings
Importantly, the Gradle Task is at the top of the list!
mind the order
Run project
Hope I could help you with that

How to Run app in Android Studio without kill and restart the session?

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

no changes to deploy android studio 2.1

Android Studio 2.1 instant run is not updating the app on the device
I observed an issue with AndroidStudio 2.1. When I run the app with small java code changes, it doesn't update app on the device sometimes. Instead it shows a message
No changes to deploy // (Don't show again)
Am I missing any thing here?
As a work around I do clean build every time in order to reflect the changes in app.
Upgrade Android studio version to 3 or more. this bug is resolved.
This was a bug on version 2.0 instant run and issues were reported check these links
https://code.google.com/p/android/issues/detail?id=199884 https://code.google.com/p/android/issues/detail?id=195062
https://code.google.com/p/android/issues/detail?id=206698
https://code.google.com/p/android/issues/detail?id=209413
https://code.google.com/p/android/issues/detail?id=206627
thing to do would be to disable Instant Run entirely by
Settings > Build, Execution, Deployment > Instant Run > Enable
Instant Run
You can file a bug at this link: Google Issue Tracker
please check this answer https://stackoverflow.com/a/35169716/2826147 to turn it off.
Thats a bug in Android Studio, I noticed it in build 2.0 sometimes it failed to update, so what i do is I rebuild the entire project, one more thing, if you have multidex enabled and your device is not running 5 <it will not work, make sure its disabled and rebuild your project.
I have just noticed that whenever i closed my app and then run it worked. See my post here.
https://stackoverflow.com/a/37357665/5923606

Android studio "Your app does not have the latest code changes.."

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

Categories

Resources