Instant Run – Android
50 times faster emulator than earlier as claimed by Google

Here is all about “Instant Run”. The most requested feature from android developers is to improve the performance of deploying and running android apps from android studio to phones/ emulators. Finally, Google released a new feature which would almost increases this process 50 times faster than it was and named it “Instant Run”.
Though it has few limitations and known issues, it allows you to make changes in your code and see them running on the emulator or device much more quickly. Google released this feature in Android Studio 2.0 preview release. Start downloading and installing Android Studio 2.0 from Canary Channel.
Easiest way to try out Instant Run is to try it with one of Android code samples. Choose


Then choose any one to import from the list of sample codes. Lets go with FloatingActionButtonBasic example.

Once the sample is imported as project, as this is existing project which is not created now, we need to configure “Instant Run” feature manually. Go to Settings to enable this feature.
In Mac, Click Android Studio -> Preferences
In Windows, File -> Settings
In Settings/Preferences, go to Build, Execution, Deployment, under it you will find Instant Run feature. This will require a new version of Gradle plugin for the project. The link to update the project is provided for the same.

After updating the Gradle plugin for the project, it will use a new faster version of dex, which helps both instant run and a full build be a bit faster. The classpath in dependences of Gradle file will have the updated gradle plugin
com.android.tools.build:gradle:2.0.0-alpha1.
Now your project is ready to use the Instant Run feature. Click on “Run” to run the project in your device or emulator. The limitation of this feature is, your project should have min API level as icecream sandwich or above.

Click on the two Floating Action buttons, you will see that they currently toggle states and log the toggle events. You can see the events by clicking “SHOW LOG” near the upper right of the emulator.
As now we have android app running, to experience the feature of Instant Run, make changes in the code to reflect instantly on the device or emulator.
Go to Application\src\main\java\com\example\android\floatingactionbarbuttonbasic\FloatingActionButtonBasicFragment.java
Add the below highlighted line
@Override
public void onCheckedChanged(FloatingActionButton fabView, boolean isChecked) {
// When a FAB is toggled, log the action.
switch (fabView.getId()){
case R.id.fab_1:
Toast.makeText(getActivity(), “Instant Run rocks!”, Toast.LENGTH_SHORT).show();
Log.d(TAG, String.format(“FAB 1 was %s.”, isChecked ? “checked” : “unchecked”));
break;
case R.id.fab_2:
Log.d(TAG, String.format(“FAB 2 was %s.”, isChecked ? “checked” : “unchecked”));
break;
default:
break;
}
}
By adding this line you need to import the Toast class as shown below:
import android.widget.Toast
Now again click on the “Run” in the toolbar. You will notice that the build is completed almost instantaneously and the emulator shows a brief message telling you that the code change has been successfully applied.Try clicking on the first Floating Action button. You will see that the code change you made is already running!

Check the complete tutorial here http://android.esprinkle.com/2015/11/instant-run-android/
Thanks for reading 👍🏻😄