user2861672
user2861672

Reputation: 51

Android Studio is very slow

I have a project with about 20 modules inside. Gradle clean takes about 5min. As ell if i add a new module gradle update projects needs more than 5min.

There are no dependencies to external libraries. Dependencies are only inside the project between several modules.

I had same Project without gradle and it worked fine. I did not convert the old project to gradle. I have created a new project with the file structure recomended by gradle. But with this performance this is not very usefull...

Any idea what's going wrong with gradle?

Upvotes: 5

Views: 18902

Answers (6)

Muhammad
Muhammad

Reputation: 425

This could help too:

If you notice that Android Studio works slowly, consider the possibility to reduce the number of folders under antivirus protection.

Each antivirus check in your project consumes resources. You can significantly improve the performance, if you exclude certain folders from the antivirus protection.

Source: tip of the day from Android Studio.

Edit: The same point was made in the 2019 Google I/O talk: https://youtu.be/8rfvfojtRss?list=WL&t=756

Upvotes: 2

user4360497
user4360497

Reputation:

I have a MacBook that I use for Android Studio and when I started out it was completely unusable taking 5 to 10 minutes for a build even for the smallest app. The Android emulator still does not work. Two things made the system usable. More memory added - I originally had 2GB and now have 8GB ... and using actual Android hardware connected via USB.

My MacBook spec is as follows - macOS Sierra Version 10.12.3 MacBook (13-inch, Mid 2010) Processor 2.4 GHz Intel Core 2 Duo Memory 8 GB 1067 MHz DDR3 Graphics NVIDIA GeForce 320M 256 MB Serial Number - oops!

The phone I use for build is an LG Sporty using Android 4.4.2 KitKat

Android Studio has the Intel HAXM extensions loaded and switched on.

Upvotes: 0

MIkka Marmik
MIkka Marmik

Reputation: 1102

Set Custom VM options in Help-->EDIT Custom VM options.

-Xms1024m
-Xmx2048m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=256m
-XX:+UseCompressedOops

File-->Setting-->Build Executions

Compiler-->Command-line options set --offline.

Gradle-->check OfflineWork.

Launch SDK Manager--> Download HAXM Installer.

Now Android studio work like charm in Windows. Happy Coding:)

Upvotes: 1

user1995307
user1995307

Reputation: 747

My Android studio in Ubuntu was too slow and I have done these things to speed up to very fast. in the welcome screen click (you can also go to it by file>close project)

 >configure>project default>
>code style > compiler > 
  click the following options 
     -make project automatically
     -use in process build
     -configure on demand
then in compiler (below the first one)
     - give build process heap size as 1000 or 1500
       (it will take a lot of RAM but Android studio will be extremely fast)
       give the same heap size for Android build and gradle build in the below tabs

Hope it will help

Upvotes: 3

Yster
Yster

Reputation: 3315

Just create a file named gradle.properties in the following directory:

/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:Users<username>.gradle (Windows)

Add this line to the file:

org.gradle.daemon=true

Source: https://www.timroes.de/2013/09/12/speed-up-gradle/

Upvotes: 8

letroll
letroll

Reputation: 1078

On Windows, I have found than my anti-spyware consider the jar files like archive. So I had exclude them from scan, but it's not very secure ....

Upvotes: 0

Related Questions