By default, Android Studio will detect changes to your code and apply the changes to UI while the app is running. This is great but only works for minor changes like changing color, fontsize, etc. But what I have noticed is that over time, Android Studio becomes really laggy in performance as the app grows in code size. The biggest performance hit is when the app is running in debug mode and I make changes. If I run the app but not in debug mode, it is still laggy but not as much. Typing in code gets a lot of freezes.
Is there a way to disable this automatic compiling of changes and updating the UI?
Search for Live Edit Of Literals in settings you will find an option to enable and disable Live Edit Of Literals as shown in below image
After some testing, it appears that this performance issue is related to the amount of code in the file you are editing. The file I was editing had a very large amount of code in it - 850 lines / 32k. But when I tried editing a file with significantly less code, there was no performance issues. Google needs to address this issue. A temporary fix is to break up the larger code into smaller files.
Related
When I open the solution I am working with, resharper takes some minutes to analyse the solution, making the IDE unresponsive.
Why does it do that if I had turned off solution wide analysis?
edit
I have got an answer that there is no actual analyze on startup if I turned off "solution wide analysis". However, on startup, there is a red animated icon in the lower right corner of the window and if I click that, the tooltip reads "Analyzing files (8 of 431)" so the suggestion that there is no solution wide analysis is contradicted by the wording.
there are multiple things you can try on the first hand.
have you trying reading
this link
or you can try showing the execution time for the solution analysis then you can see where it got stuck for minutes.
or you can try this too.
Go to ReSharper | Options | Environment | Performance Guide to check and quickly fix ReSharper and Visual Studio preferences that affect performance.
If you do not use solution-wide analysis, disable it or consider disabling warnings in solution-wide analysis. Even if it is disabled, you can find all code issues in your solution at any time by running code inspection for the whole solution. To configure solution-wide analysis, go to ReSharper | Options | Code Inspection | Settings.
In Visual Studio options, go to Source Control | Plug-in Selection: select None for the source control plugin. This will turn off Git or another VCS provider and improve overall performance.
ReSharper builds or updates indexes on startup. The indexes are used for basic ReSharper's functionality: navigation, refactoring, code analysis in open files, etc...
If you see IDE unresponsiveness, you can collect timeline perfomance snapshot and send it to JetBrains for investigation. Instructrions for submitting performance problem can be found here (you need to select "Performance snapshot(timeline)":
https://resharper-support.jetbrains.com/hc/en-us/articles/207243205-How-to-collect-a-performance-snapshot-and-send-it-to-JetBrains-Team
I'm using Android Studio 1.5.1 on Kubuntu 15.10 and lately, Android Studio freezes completely whenever I right click into the project explorer. The only thing I can do then is to kill the process.
More oddly, whenever I hover the Help menu with the mouse, the complete OS freezes completely and I have to restart the computer. I am not 100% sure if these two issues are related, but they started at the same time.
Sometimes (about 10% of the time) it works well. I have no idea what influences this pattern, though. This used to happen earlier as well, but much less frequent.
The usage of different color schemes or deactivating plugins seem to have no influence on this behavior. I also did not install any fishy third party software or anything else that could (to my knowledge) have influenced this. Any ideas?
The issue seems to be resolved in the latest stable release (2.0).
I've recently run into this as well. Pointing jstack at the hung process suggests that it's this problem.
Switching to the Darcula or GTK+ theme resolved it for me. Weirdly, I can switch back to the Intellij theme afterwards and the problem stays fixed - I just have to switch to GTK+ or Darcula at some point after startup but before triggering a right-click menu.
Edit, 1 day later: In a deeply unimpressive plot twist, this solution no longer works for me. I've changed nothing since yesterday, but now attempting to switch themes triggers the lockup ಠ_ಠ
Edit, 1 day, 5 minutes later: After a restart the situation improved slightly - changing the theme now works again, and avoids the freeze-on-rightclick failure. I'm finding it difficult to take this as much of a victory.
Edit: As karpfen notes below, this issue has been resolved in the latest release. Huzzah!
The current Android Studio version has inbuilt auto save. Which means if you close a file, it will automatically save the changes.
This is inconvenient, it means when experimenting with code, all changes need to be noted as there's no option to have a dialog requesting to save changes on closing a tab or the project, as in many other ides.
According to documentation IntelliJ IDEA 15.0 Help/Saving and Reverting Changes:
When does IntelliJ IDEA auto save changed files?
Autosave is initiated by:
Compiling a project, a module or a class
Starting a run/debug configuration
Performing a version control operation such as pull, commit, push, etc.
Closing a file in the editor
Closing a project
Quitting the IDE
.../...
Note that those are optional autosave triggers, and you cannot turn off autosave completely.
These are the auto save settings that can be changed in Android Studio:
TLDR
Is there any work around to circumvent this autosave?
These questions are related, but do not acknowledge that this intended behaviour of the ide and are rather asking for fixes within the ide.
Related:
How to disable Auto Save save in Android Studio
How turn off autosave in Android Studio?
If you want to experiment, use the revert button at the top right. This works especially well if you are using a VCS (like git...) as it will revert to the last committed version. And since commits are still manual, this will soon replace your traditional save.
If you are not using a VCS the point in time to which it reverts is a little more arbitrary, but in my experience it takes a pretty good guess. If that doesn't suffice, you can use the history button next to the revert button, which keeps track of every version IntelliJ saved, and you can then go back to any point in time you like. :)
Android Studio as a software is very much based on the JetBrains software solutions such as IntelliJ (used for Java) and PHPStorm (used for PHP, as its name shows).
As a concept in itself, JetBrains have implemented this feature and as a company believe that it's much more efficient and productive than manual save. Hence, there is no way to disable this behavior or enable any confirmations in Android Studio either.
Taken from JetBrains FAQ for IntelliJ:
Because IntelliJ IDEA has the ability to change so many files simultaneously in large refactoring actions, and change them without ever opening them, single file saves don't make very much sense. In recognition of this, IntelliJ IDEA reserves the right to save any of your files literally whenever it wishes. It's actually quite nice to never have to worry about your file's save statuses, once you get used to it.
Having said that, and encountering this issue myself too as a developer, I agree that it would be a good idea if the Manual Save feature were enabled by the Android Engineers (or JetBrains themselves). After all it is up to the developer to choose whether he needs this feature or not.
To Jetbrain's defence, they have a very good Undo function through their Ctrl + Z shortcut keys, letting the developer go back many steps and find where a certain error has occured.
All IntelliJ based products nowadays save any opened or modified files whenever they wish - read this as "immediately".
I would suggest you give up on trying to disable it (trust me, it's not possible to hack it) and either change your work flow or work on copies of the files.
As background I should mention that I am a plugins author for IntelliJ (with 3 publicly released plugins in the JetBrains repository) and thus have a reasonable understanding of the internal IntelliJ architecture.
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.
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
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
When MonoDevelop crashes (somewhat often unfortunately) I usually have to re-do changes to the project that seem to not be written to disk. As a result my work flow has become - change project, restart monodevelop (hoping changes are saved during a close). I find this to be a little frustrating. Ideally there would be an explicit save button in the UI so that I know for a fact my changes are written when I expected them to be. I am not sure where to file enhancements requests - through Xamarin (since this is monodevelop with monotouch)? Any chance someone has written an Add-In to do this?
If everything is OK with your MD installation the Save All command/button should save all the project files and solution. I regularly use this command as a safeguard. On my experience just hitting Save only saves the file you are editing on the moment, keeping the solution and project files unsaved.