android - Android SlowGradleBuild

标签 android gradle kotlin

您好,在AndroidStudio + Kotlin中进行更新后,我的gradle需要5分钟以上的时间。 gradle Sync进行得很快,但是gradle构建将永远加载。

这是我的build.gradle:

Apply插件:'com.android.application'

Apply插件:'kotlin-android'

请检查以下代码,并提供任何建议以帮助我。

android {

    compileSdkVersion 26
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "myApp"
        minSdkVersion 20
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/res/fonts'] } }
    }

    dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.github.jkcclemens:khttp:0.1.0'
    implementation 'com.github.devlight:infinitecycleviewpager:1.0.2'
    implementation 'com.github.kittinunf.fuel:fuel:1.12.1'
    implementation ('com.yarolegovich:discrete-scrollview:1.3.0') {
        transitive = false

    }
    implementation 'com.amazonaws:aws-android-sdk-s3:2.6.18'
    implementation 'com.github.whalemare:sheetmenu:1.3.3'
    implementation 'com.amazonaws:aws-android-sdk-core:2.6.18'

    implementation ('com.squareup.picasso:picasso:2.5.2'){
        transitive = false

    }


    }

    allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    }
    repositories {
    mavenCentral()
    }

最佳答案

如果您增加了项目中的堆大小,这可能是解决方案:

为了加快构建速度,请将Gradle守护程序的最大堆大小增加到至少4608 MB(基于dexOptions.javaMaxHeapSize = 4g)。 (这是示例大小,您的可能会有所不同)

为此,请在项目gradle.properties中设置org.gradle.jvmargs = -Xmx4608M。

有关更多信息,请参见https://docs.gradle.org/current/userguide/build_environment.html

关于android - Android SlowGradleBuild,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50023648/

相关文章:

java - ListView Adapter 如何跳过数据

java - 如何从Android中的另一个Java类调用方法?

android - 如何在 phonegap 中使用插件来改变屏幕方向?

intellij-idea - Kotlin 意外 `unresolved reference`

android - Android Mockito-Kotlin错误- “Actually, there were zero interactions with this mock”

android - 服务可以在 Android M 中请求权限吗?

gradle - 在根项目中找不到带有路径的项目

java - 我如何在 spring boot 中更改 logback 版本?

android - 如何修复 Android Studio 无法连接到 Gradle 守护进程?

java - Android本地VPN服务: can't get response