Android Studio变得非常缓慢,并且不断“更新索引”

SO上有更多类似的问题,但我还没有找到我的答案,所以我正在打开一个新的。

我正在使用:

Android Studio 2.2.3 (但与 2.2.2 相同) Gradle 2.14.1 JRE 1.8.0

我正在Mac上使用它,OS X El Capitan(2.5 GHz,i5,8GB RAM)。

直到几周前,它一直运作良好,现在它是如此痛苦地缓慢。大多数时候,它是“索引/更新索引”。

我并不担心构建时间(大约需要30-40秒,但我可以忍受这一点),而是不断的索引使得编码几乎不可能(整体响应能力很差)。

我的 gradle 文件中是否有任何内容可能导致此问题?

我确实有一些依赖项,但应用程序本身相对简单。

build.gradle //app

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {

compileSdkVersion 23
buildToolsVersion "23.0.2"

dataBinding {
    enabled = true
}

defaultConfig {
    applicationId "com.example.myproduct"
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
   }
}
dependencies {

    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.+'
    compile 'com.android.support:support-v4:23.2.+'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:design:23.2.+'

    compile 'com.jakewharton.threetenabp:threetenabp:1.0.4'

    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'

    compile 'io.reactivex:rxjava:1.0.10'
    compile 'io.reactivex:rxandroid:1.1.0'

    compile 'com.google.android.gms:play-services-auth:8.3.0'
    compile 'com.facebook.android:facebook-android-sdk:4.16.1'
}

build.gradle//project

 buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

        classpath 'com.google.gms:google-services:1.5.0-beta2'

       }
    }

    allprojects {
        repositories {
            jcenter()
        }
    }

    task clean(type: Delete) {
            delete rootProject.buildDir
    }

附言:我已启用 - 脱机工作,并行和守护程序。我增加了 VM 堆大小。我已经上传到最新的Android Studio。我用jcenter()替换了maven。我错过了什么吗?


答案 1

这也发生在我身上,我只是同步“应用程序”,它被解决了...

或者使用这个

使缓存失效/在“文件菜单”下重新启动


答案 2

对于其他有相同问题的人:

我的Android工作室恢复了原来的性能(没关系)。我很难说是什么做出了改进,因为我一次做了很多改变,我记得这里很少:

  • 将 maven 替换为 -> jcenter()
  • 在属性中设置标志以使用默认的 gradle 包装器
  • 将Android工作室更新到最新版本(目前为2.2.3)
  • 已启用的 gradle 守护程序 - 按需配置
  • 使缓存无效并重新启动(几次)

在提出这个问题之前,我已经尝试过其中的一些,但我认为当我上次更新到Android studio 2.2.3时,一切都恢复了正常。


推荐