Why starting project (Run) in Android Studio triggers APK rebuild even if no changes were made? - android-studio

I mean, we are in 2016 and this is not a Borland compiler.
The point of Run operation is to start the package on device. If no changes are made since last run, just run the APK, but this Gradle thing cannot manage it and runs in whole project compile each time (2-3 minutes). Components are not recompiled, but the whole package construction takes that time.
I wonder how the whole world of Android developers tolerates this (and other quirks of gradle). I searched in Google and found no solution. Any hints to make it better?

You can't do anything about it; Android Studio just has to rebuild every time. But in the newer versions of Android Studio, you can use Instant Run. This runs/debugs your applications by using a simpler Gradle build in a very fast matter.
Also, take a look at this , which previously helped me to reduce my Gradle build from 45 to 7 seconds.

Related

Android Studio 2020.3.1 - Run very slow, always re-build

I'm using latest AS, version 2020.3.1. Every time I change the code and run it again, AS run very slow, always re-build project (take about 10 minutes). My project is also quite large, using many libraries.
How to make AS run faster?
Please help me. Thanks.
It all depends on your system configurations. It does not matter which android studio version you are using. Try upgrading your machine or prevent using inbuilt AVD of android studio rather use your own mobile for testing. This could make Your AS run a bit faster.
Here is the link to know how it is done
https://developer.android.com/studio/run/device

Android Studio 3.0 VERY VERY VERY slow on run

I have a very big problem using Android Studio.
Every time I make a code changing, I have to check if all has gone well launching my app; but as soon as I click the "Run app" or the "Apply changes", it's the end: it starts the Gradle build process, which take even 30 minutes to complete, and furthermore Android Studio take the full control of my computer, not allowing to do nothing anymore (like open the browser, open notepad++, and so on...).
Can anyone help me?
Thanks
If you use Eclipse you won't have this problem anymore. but if you want to stick with android studio and gradle you can run your emulator and gradle once and whenever you want to compile your code run it on the already built gradle. this means that do not close the emulator and run your program on it again and again. this way you will not have to spent alot of time on loading the emulator and gradle
Android Studio is not a very light software.It uses a lot of your system RAM and CPU power.So if you are using an old system then it is obvious that android studio will run slow.If possible then upgrade your system.
And one more thing it's better to use actual device rather than Virtual Emulator for our application working test.

Android Studio - automatic gradle sync at startup

Yesterday I updated the Android Studio to 2.2 (from 2.1.3). Since that the Android Studio always start gradle sync at startup on every opened projects. I found this question and I tried Mick's suggestion, but unfortunately that did'nt worked for me.
If I open Android Studio, and I wait until load my projects, sync gradle and then I close Android Studio (without any change on my projects), and after that, I open it again, AS also do the same as before (run a gradle sync again senselessly).
I think, this is not a serious problem, but it's pretty weird, because it sync senselessly (otherwise I start gradle sync manually if I need to, but AS start it on every startup senselessly), and I need to wait little more to start coding (a little waste of time and energy).
Maybe this is what you want.
gradle --stop

Does Intellij Idea have instant run?

It is some time now since I first heard about instant run in Android Studio 2.0. Is it ever coming to IntelliJ Idea? I have 2016.1.2 and still nothing. I can imagine it can speed up development. I am still tearing my hair every time I press run...
Couldn't find any valuable information about this online. All what google finds is just "IntelliJ and Android Studio is made on the same code base" I guess it is more complicated than that.
Seems like it's going to be released in Intellij 2016.2
Quoting 2016.2 EAP Release Notes:
Android
Android Studio 2.0 features.
Edit:
Looks like it was eventually released and made production ready in Intellij 2017.1
Quoting the What's New page:
Instant run
This release adds many stability and reliability improvements to
Instant Run. If you have previously disabled Instant Run, the Android
team encourages you to re-enable it.
No. From IntelliJ IDEA 2016.2 Notes:
Android
The update includes the Android Studio 2.0 features: faster Emulator, experiment GPU Debugger, faster full builds, and code generation and testing for App Indexing. Note, Instant Run is not fully-merged yet.

Android Studio avoid "make" while running

When you press the run button in Android Studio the project is buit again, and as you know this always take long, if e.g. I select Build -> Make Project and then "Run" the make process runs again, I don't understand why? I would expect that it only installs the APK that is already generated. Is there a way I can achieve this, is my expectation funded or am I thinking wrong?
I've used the approach described here to speedup my build.
Building and running app via Gradle and Android Studio is slower than via Eclipse
At the same time i've disabled "make project automatically" because sometime it produces old code.

Resources