Reputation: 73
Same SSD, the same project, the same version of Android Studio. Dual boot W10 and Ubuntu 17.10. On Ubuntu, Android Studio launches, loads the project and finishes sync and gradle compilation in 12-14 seconds, on Windows 10 it takes 53 seconds.
Fresh install multiple times on both systems. Also, on a late 2015 iMac with system configuration almost identical to my pc, the times are almost identical to those on Linux.
YOUTUBE: Windows vs. Linux (Android Studio): https://youtube.com/watch?v=K4HR2pVQdDo
LE: After I disable windows defender for all folders with Android Studio, Android SDK and project folder and deactivate the Windows Search service, I reduced to 38 seconds.
I still have a huge difference over the 12-14 seconds on Linux and MacOS. Fresh install of W10 with up-to-date updates.
On Windows after the project is loaded, Android Studio does some gradle and sync compilations for more than 20 seconds. On Linux and macOS it takes up to 4 seconds.
What is the explanation and how can Android Studio upload the project in Windows as fast as it does it on Ubuntu and MacOS?
This happens every time I start Android Studio and open the project (later compilations are also fast on Windows, although Linux and MacOS are faster).
Why is so slow on Windows?
Is there any conclusion / resolution? Or is Windows really an Android & Java development avoided OS?
Those steps that run only on Windows I do not manage to see on Linux and macOS - or they run instantly or they don't run at all, but it is certain that those things take over 20 seconds on Windows:
IMAGE: Windows gradle compilation and sync, takes over 20 seconds
Upvotes: 7
Views: 5813
Reputation: 5298
Try disabling anti-virus protection for your Gradle caches directory, Android Studio project directory, and additional Android directories listed below. For me, this made a huge difference. From what I've read, a big chunk of time is spent doing anti-virus scanning on intermediate files and JARs, and this dramatically slows Java compilation. Excluding those same directories from Windows search indexing can also help.
As of September, 2020, this is the list of default directory locations that should be exluded from virus scanning and Windows search indexing, published here.
%USERPROFILE%\.gradle
%USERPROFILE%\AndroidStudioProjects
%USERPROFILE%\AppData\Local\Android\SDK
%USERPROFILE%\.AndroidStudio<version>\system
I published some instructions on my blog for doing this for Windows Defender and Windows Search Indexing, which I'll repost here for completeness:
Windows Defender - How to Exclude a Directory
Windows Search Indexing - How to Exclude A Directory
Upvotes: 2
Reputation: 1252
So damn true! I experienced the same thing. Build time go down to hell on Windows and go up to heaven on Ubuntu/Linux distros, even on very very strong CPU power computer. I guess JVM is just simply can't perform well on Windows OS.
Upvotes: 1