10

I have a Laptop with a Core i3 processor and a 2GB of RAM, and I am using my Sony Xperia C as an alternative to the Emulator. When I click on debug and choose my mobile device, the Gradle starts building and it takes about 5 to 10 minutes to finish. I understand that I have very low resources but I doubt that there is another reason why it takes too long time to finish building and running the app.

I noticed in the logcat tab that it is spending the time on sending a request and waiting for a response repeatedly..

Can anyone tell me if the problem is with the hardware resources or my doubts are true about the cause being something else.

AliSmart
  • 185
  • 2
  • 2
  • 14
  • Gradle is a very heavy build tool. Even on my work I7 laptop with 8GB ram, browsing the web will lag if I have a gradle build running. The most you can do is try tweaking a couple of settings, (see http://stackoverflow.com/questions/17324849/android-studio-gradle-build-speed-up) but that doesn't always provide much of a performance increase. – Warrick Jun 24 '16 at 02:35
  • Thank you, but why would the RAM be the problem if I still have a 500MB free while Studio is running since I am debugging on a real device. isn't the problem related to CPU? – AliSmart Jun 24 '16 at 02:55
  • Ram is kinda complicated. One reason however would be that Android studio runs inside a Java VM, which manages all the ram. 500mb free is pretty low, especially for a development computer. – Warrick Jun 24 '16 at 03:19
  • You are totally right :( – AliSmart Jun 24 '16 at 03:29

6 Answers6

10

Android Studio is very resource hungry. I use an old Sony with Core 2 Duo and 2.5 GB of RAM, with tweaked system that running about 200MB for the operating system. It takes about 10 minutes or more to build a project.

My suggestion, upgrade your Laptop RAM to 4GB or more. 8GB should be enough. Now I'm working with 4GB and Corei5 where Android Studio take about < 1 minutes to run a project, but it depends of the project size and its dependencies.

-- UPDATE --

Default setting of Windows 10 will use about >90% of your disk which will make your building process much more slower. You could decrease it to <12% by simply turning off "Show Me About Windows":

From the Windows Menu, go to Settings, then go to System and then go to Notifications and Actions. Turn off "Show Me Tips About Windows"

update reference: Disk usage always at 100%

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • Hmm.. but why do you think the problem is with the RAM? I coped it by running the app or a real device, and I still have a plenty of 500 MB free along with Android Studio running on Windows 10. – AliSmart Jun 24 '16 at 02:51
  • Well because you only can use about 1GB. The other 1GB is already by Windows 10. Windows 10 requirement is about 2GB for for 64 bit [Windows 10 Requirement](https://www.microsoft.com/en-us/windows/windows-10-specifications), that's the minimum requirement for working. imho, Windows 10 locking some memory space for itself. The memory space is reserved for internal process. – ישו אוהב אותך Jun 24 '16 at 03:00
  • I am running Windows 10 for 32 bit. in the task manager it is labelled as process "System" taking 260MB, and I was doing experiments on using Emulators before running on my real device. I could use 98% of memory when I had the Emulator (512MB) + Android Studio + Win10 all working together. the remaining 2% i think is due to lack of memory addressing by cpu – AliSmart Jun 24 '16 at 03:06
  • Well, process labeled with "System" is not representing for all Windows 10 processes. Add a column "Publisher" in your task manager, and see the processes with "Microsoft Corporation" label. Please check about the VM that Android Studio use. Maybe it will give us some clue. But I can't tell you more about it. I only use Windows 10 in my office. My main os is Linux :) – ישו אוהב אותך Jun 24 '16 at 03:14
  • Note that sometimes Android Studio takes too much time just to install apk to device. And it often happens with me..:(. – ישו אוהב אותך Jun 24 '16 at 03:16
  • I think you are right for the VM idea ;) What makes sense is the question: why didn't they invest much in engineering when they developed Android Studio :S ? – AliSmart Jun 24 '16 at 03:26
  • I could'nt say more about google effort on Android Studio. Maybe they still working on the problem. But as far as I know, the main developer is JetBrains – ישו אוהב אותך Jun 24 '16 at 04:08
  • @AliSmart: see my updated answer for tweaking your Windows 10. Maybe it could be a help. – ישו אוהב אותך Jun 24 '16 at 05:28
  • Thank you so much, it seems that "Show Me Tips About Windows" option doesn't exist in all versions of win10. anyway I could cope with the problem by setting my gradle and compiler options to be offline – AliSmart Jun 25 '16 at 09:23
  • @AliSmart: read the linked article, there is other option to make your memory usage lower..:) – ישו אוהב אותך Jun 25 '16 at 09:27
  • I will, and I am very grateful for your help :) – AliSmart Jun 25 '16 at 09:32
3

I would strongly recommend that you either upgrade your development machine's RAM (8GB or more) since 2 GB ram will be too painful for studio.

Also I recommend: open single project at a time and clean your project after running your app in emulator every time.

Developer
  • 45
  • 1
  • 10
  • 1
    imho, cleaning a project will be a bad idea because we must rebuild it again and it consumes more time. Only clean when we sure that something wrong with Android Studio, like unupdated resource file in project or unupdated dependency. – ישו אוהב אותך Jun 24 '16 at 03:05
1

After upgrade your RAM, you should try to upgrade Android Studio. In Android Studio v2.0.0 ++ , they support Instant Run

Android Studio now deploys clean builds faster than ever before. Additionally, pushing incremental code changes to the emulator or a physical device is now almost instantaneous. Review your updates without redeploying a new debug build or, in many cases, without restarting the app.

More info about Instant Run

Fuyuba
  • 191
  • 1
  • 8
1

In my case, I don't use debugger for monitoring app performance ...etc, So I do not install app to device (I build application only instead of run), then I use adb to install apk to device ...

adb install -rst <$$path_to>.apk

path_to_apk is where my apk gets built Usually ...

<$$build_path>/android-build/build/outputs/apk/my.apk

I get things work with a reasonable speed , offcourse, on the cost of debugger!
I am then trying how to activate debugging from adb! if possible and needed.

Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47
0

I recommend that you upgrade your ram so that your Android Studio will run normally (Technically speaking: It will have enough resources to use). I use a core i3 4gb RAM system and it feels a little slow to me too.

Check this image...

Requirements to run Android Studio

Kill some background processes and then start your android studio (This is a temporary solution) or upgrade your RAM.

Nikhil Kamath
  • 95
  • 1
  • 1
  • 12
0

While debugging disable Instant Run and try again.

Ali Akram
  • 4,803
  • 3
  • 29
  • 38