I have a Hp envy notebook with Intel i7 and 8gb ram and 2gb graphics, still sometimes android studio stucks when I am working with xml or design the app. Is there any problem with my laptop or android studio?
If Android Studio has a proxy server setting and can't reach the server then it takes a long time to build, probably its trying to reach the proxy server and waiting for a timeout. When I removed the proxy server setting its working fine.
In Android Studio, you will see all the projects's XML files and can edit them with all the tools Android Studio provides, including the visual designers. As you make changes and save them in Android Studio, they will automatically reflect back into your Elements project inside Visual Studio.
Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts. You can also use Android Studio's Layout Editor to build your XML layout using a drag-and-drop interface.
Android applications use XML to create layout files. Unlike HTML, XML is case-sensitive, requires each tag be closed, and preserves whitespace.
It's probably because there's not enough heap memory for AS. You might want to try the first technique mentioned in this blog: Eliminate Lags & Stutters in Android Studio.
Content of link
Increasing Android Studio's Memory Heap:
Android Studio, like other Java applications, is known for hogging an insane amount of memory while running. Unless enough memory is allocated to the IDE at launch, disk swapping will start kicking in and if you're not using a SSD, God bless you.
Open the file [AS Installation Folder]\bin\studio64.exe.vmoptions
or studio.exe.vmoptions
, depending on which version you're using.
In it you're likely to find these two lines at the top:
-Xms128m -Xmx750m
Increase the two values to something reasonable, e.g. -Xms256
and -Xmx1024
. You can boost the second value to 2048 if you like; my coworker whose computer has 8G of RAM doesn't find any issue with -Xmx2048 either.
After you're done, restart AS and if you've checked Show memory indicator in Settings/Appearance, you'll see something like this at the bottom-right corner:
Speeding up Gradle build time
One of the reasons developers are still hesistant to ditch Eclipse is because of Gradle. Although it's indeed a nice build system and there are many benefits to using it, even the simplest Gradle calls are pretty slow and time-consuming. As a consequence, our workflow includes a lot of unavoidable waiting, and sometimes we even forget what needs to be tested after AS finishes its laborious building processes. There are a few things we do to boost Gradle's speed.
First, go to Settings/Compiler
and check everything, except for the 2nd option Make project automatically. For VM Options, we use these configurations:
-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Next, add the following lines to gradle.properties in your project directory:
org.gradle.daemon=true org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.parallel=true org.gradle.configureondemand=true
Accelerating the emulator with hardware virtualization
Although the Android emulator is not part of Android Studio, it's well worth mentioning that if you're using one of the newer Intel CPUs which support hardware virtualization, the emulator can be amazingly fast. Check out this article for how to set it up on your machine.
In case anyone else encounters this in the future, I've found that if you click on the little man with the hat at the bottom right, enable "Power Saving Mode" and switch down Highlighting level to "None", it reduces the XML editing lag in complex layouts.
Once you make the edit, you can disable Power Saving and slide highlighting back up to see the changes in Preview.
Not ideal, but it prevents the constant pauses between keypresses whilst editing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With