Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 1.1.0 hangs while editing build.gradle

My machine has 8 GB of RAM. I installed Android Studio 1.1.0 and applied everything they posted here.

Everything works fine with a small Hello world app. But when I start editing build.gradle of a big project which we had moved from Eclipse, the IDE hangs for 20 or 30 seconds. It hangs even if I don't add or remove any lines. Even if I just press Enter. Besides I don't see any processes running (indexing, syncing, etc) at the bottom.

I checked File -> Settings -> Gradle, and Use auto-import was unchecked.

As they suggested, I ran jstack -l <pid> > dump.txt and posted a message along with dump.txt on https://code.google.com/p/android/issues/detail?id=82706#c35

I can't attach the same dump.txt here because it contains about 800 lines.

like image 378
Maksim Dmitriev Avatar asked Apr 30 '15 14:04

Maksim Dmitriev


2 Answers

After some time looking into this issue, I found that it is an active issue among the Android Issue Tracker forum.

https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=59965

You'll see my comment in that thread but I'll post it here as well

I did find out WHY my build.grade would hang upon touching (any amount of editing once so ever).

I had a statement where I would iterate over all the variants and would then iterate over each variant's outputs and do a filter among an xml file. Commenting the filter portion out would remove the hanging/freezing problem. In fact only iterating over the first output (of the first variant) would drastically reduce this lag time, still, very annoying.

I would suggest starting your build.gradle file from scratch and adding parts progressively until you come across the portion in which hangs the editing process.

EITHER WAY, this hang shouldn't happen since I'm merely editing the file, not compiling nor running.

Hopefully this can help someone

like image 101
ElliotM Avatar answered Sep 27 '22 19:09

ElliotM


In your gradle.properties files uncomment the 3rd line below, if not exist create one yourself

# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

This help me a lot in android-studio performance

like image 38
Ramon Felix Avatar answered Sep 27 '22 20:09

Ramon Felix