The past few days, I've experienced some unusual problems in Android Studio 2.3.1; the IDE freezes whenever I edit the build.gradle (module) file.
My Project-level gradle settings are Use default gradle wrapper (recommended)
gradle-wrapper.properties
is as follows:distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
My local Gradle version (defined by GRADLE_USER_HOME) is Gradle 3.5
Android Studio does not have a proxy server setting enabled as described in this post Android Studio gradle takes too long to build
my
gradle.properties
file is as followsorg.gradle.daemon=true org.gradle.parallel=true
my
build.gradle
file is as followsapply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.3" defaultConfig { applicationId "app.com.eventfull.waterjam" minSdkVersion 16 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dataBinding.enabled=true } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.google.firebase:firebase-auth:10.0.1' compile 'com.firebaseui:firebase-ui-database:1.0.0' compile 'com.google.firebase:firebase-database:10.0.1' compile 'com.android.support:design:25.3.1' compile 'com.android.support:support-v4:25.3.1' testCompile 'junit:junit:4.12' } apply plugin: 'com.google.gms.google-services'
I tried toggling the offline work option in Global Gradle Settings (Settings > Preferences > Build, Execution, Deployment > Gradle), but this has no effect; IDE still hangs up when editing the build.gradle
file. Thoughts?
EDITS:
Here are my custom VM OPTIONS.
-Xms512m
-Xmx2g
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops
A complete un-install & re-install seems to have fixed this issue.
I dislike resorting to such measures - I'd rather know the why - but it was nonetheless effective.
UPDATES on 6.25.2017
Despite uninstalling & reinstalling Android Studio, Gradle, rebooting my system, cleaning various system caches a few times...Android Studio still freezes for ~30s to 60secs upon editing a gradle file. I've taken to editing the gradle files in an external text editor & Sync Project with Gradle Files. It helps, but Android Studio still seems to freeze intermittently for ~20secs or longer after doing this. Toggling the "offline mode" in gradle settings does nothing.
I'm using...
Android Studio 2.3.3 (for production apps)
Android Studio 3.0 canary 4 (for experimenting & ideas).
'com.android.tools.build:gradle:2.3.3' is the gradle android build tools in Android 2.3.3
Macbook Pro (Mid 2015), Core-i7, 16GB RAM, Sierra 10.12.5
Let me know if someone has any suggestions...
UPDATE 4/02/2018
The problem has disappeared since Google added a special repository for Android Studio users, that is, the embedded Maven repository for Android Studio 3+.
Android Studio 2.3.3 and lower doesn't have this.
INSTRUCTIONS
- Open Android Studio's Preferences - ⌘, (mac) or CTRL ALT S (win)
- search for 'embedded'
- click Enable embedded Maven repository
build.gradle
, turn off the computer network. – Soandso