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
Related
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.
I opened a folder in Android Studio which contains a Kotlin script file (.kts). I configured a JDK as SDK in Project Structure (but I added no gradle files), and running the file as Kotlin script works fine. However the syntax highlighting is only PARTIALLY working, see below example (Linux Mint 19.3 and AS 4.1.3):
Some of the stuff missing:
unused variable should be gray (val unused)
to/forEach keyword should be yellow and italic
misspelled variable names should be red
bad style such as extra spaces should be underlined
etc.
What's even going on here? Is this some sort of "fallback" mode?
Any way to use the "full" syntax highlighting from normal Android projects, so I can spot mistakes earlier?
For reference, this is what it "should" look like (pasted into a random Android project):
Renaming the file to end in *.main.kts (scriptname.main.kts) enabled full highlighting for me!
I get this type of issues from time to time with IntelliJ IDEA. I haven't found the reason why it happens, neither do I know the 100% working solution. But here are the options that usually help me solve it:
Restart IDE
Invalidating caches: File > Invalidate Caches...
Re-import the project. Remove the .idea folder and the project.iml file and try to import the project again.
Update the IDE. Last time I had this issue, nothing helped but updating IDEA to 2021.1.
I hope some of these options will help.
I know this has been asked many times, but usually the advice is something along the lines of "decrease Android gradle plugins version" or something like that. Firstly, that doesn't seem to work for me, secondly, decreasing the version in order to solve this kind of problem doesn't seem like a good practice and I'd like to avoid it (especially since Android Studio warns me I should increase the version back again when I try to decrease it).
So now what exactly is happening + some details that might help:
Every class is underlined with red color in the project explorer and there are loads of "java package R does not exist" messages in the Problems view
When I open any class, suddenly its red underline disappears and there are actually no errors in this class
It happens if and only if AS does an automatic build (I can see "21:03 Auto build completed with errors" in the Event log). When I build manually, there are no errors in the Problems view, and no class is underlined (that is, until AS does auto build again, which happens all the time)
In any way, this doesn't prevent building of the application/APK/AAB, installing it on the phone/virtual, and running it
This has been happening ever since I updated Android Studio to v4.1 (I now use Android gradle plugin v4.1.0)
(Of course, I also tried all the obvious stuff - deleting every temporary/generated file, invalidating cache, restarting, cleaning, etc. etc. Everything I could think of.)
I had a problem like this before, it had nothing to do with the gradle ijust add "import com.package.appname.R;" into myclass and is worked
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!
I've recently upgraded to IntelliJ 11 and use it for writing both Java and Groovy.
When I adjust the Project Structure to include src/test/groovy as a Test Source, the setting takes initially.
After a short while, the setting is reverted and src/test/groovy displays as a normal file structure.
Searching around, in Settings > File Associations, *.groovy is indicated as a valid source file.
I've been using IntelliJ for a while, but I'm stumped on this one.
Thanks!
The answer for me turned out to be to correct any Project Structure appears reported by IntelliJ as mentioned above.
At some time I realized this problem would occur every time I changed a POM. To resolve it (at least for now...), under Settings > Maven > Importing, I checked "Keep source and test folder on reimport", and the situation appears to have resolved itself.