Gradle需要很长时间才能构建 [英] Gradle is taking a long time to build

查看:369
本文介绍了Gradle需要很长时间才能构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

突然之间,我的gradle构建变得非常缓慢,就像它做了一些以前不曾在这里做的额外工作一样,是来自build的图片:

All of a sudden my gradle build has become really really slow seams like its doing some extra work that it didn't used to do here is a picture from build :

如您所见,这里有很多任务,以前需要10秒钟才能完成构建,现在要花几分钟才能构建出什么问题呢?它在底部栏中编写了一些内容,例如为kotlin解决了一些库,并进行了与缓存变量属性匹配缓存"有关的操作,如下图所示: 我试图激活注释处理器,这是我的gradle代码:

as you can see there are a lot of tasks here it used to be build in like 10 seconds now it takes minutes to build whats wrong with it? it writes things in the bottom bar like resolving some libraries for kotlin and doing something related to caching "variant attribute matching cache" here is the picture : i was trying to activate the annotation processor that it happend here is my gradle codes:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.example.moein.volley_download_kotlin"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    testInstrumentationRunner     "android.support.test.runner.AndroidJUnitRunner"
    javaCompileOptions{
        annotationProcessorOptions {
            includeCompileClasspath true
        }
    }
 }
 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-             core:3.0.2'

implementation 'com.tonyodev.fetch2downloaders:fetch2downloaders:2.0.0-RC21'
implementation 'com.android.volley:volley:1.1.0'

implementation 'com.google.dagger:dagger:2.13'
annotationProcessor 'com.google.dagger:dagger-compiler:2.13'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.13'
}

和其他代码

buildscript {
ext.kotlin_version = '1.2.30'
repositories {
    google()
    jcenter()
 }
 dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
  }

  allprojects {
  repositories {
    google()
    jcenter()
  }
  }

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

推荐答案

  • 渐变设置中,离线检查工作.
  • 清理并重建项目.
  • 在Gradle脚本目录的gradle.properties中(即〜/.gradle/gradle.properties)中添加

    • In gradle setting check work offline.
    • Clean and rebuild your project.
    • In gradle.properties in Gradle scripts directory(i.e., ~/.gradle/gradle.properties), add

          org.gradle.parallel=true
          org.gradle.daemon=true
      

    • 此设置对我有很大帮助.

      This settings have helped me a lot.

      这篇关于Gradle需要很长时间才能构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆