【问题标题】:Slow build gradle in android在android中缓慢构建gradle
【发布时间】:2017-07-25 04:27:14
【问题描述】:

我检查了所有关于慢速 gradle build 的问题。 (例如herehere 和...)。但是在我的项目中构建 gradle 太慢了。有时候哪栋楼要花5-8分钟,我在很多网站上搜索过,现在我累了

构建.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '25.0.2'
    defaultConfig {
        applicationId "..."
        minSdkVersion 14
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"

        jackOptions {
            enabled true
            additionalParameters('jack.incremental': 'true')
        }


        dexOptions {
            incremental true
            javaMaxHeapSize "4g"
        }
    }


    compileOptions {
        incremental true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }



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

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    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:24.2.1'
    testCompile 'junit:junit:4.12'
    compile files('libs/TelegramNewApiLibrary.jar')
    compile files('libs/TelegramNewConvert.jar')
}
repositories {
    mavenCentral()
}

build.gradle(模块应用):

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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


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

allprojects {
    repositories {
        jcenter()
    }
}

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

gradle.properties:

org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
 org.gradle.parallel=true
 org.gradle.daemon = true

我的防病毒软件被禁用,并且在项目中启用了脱机工作。

系统内存:4G

系统 CPU : 3.10 GH

Android Studio 版本:2.2.3

谁能帮帮我?

【问题讨论】:

  • :app:transformJackWithJackForDebug >> 这很慢。我认为它的杰克选项
  • 我对 android 了解不多,也不知道这个 dask 是干什么用的,或者它有什么作用。但如果这很慢,你真的有 gradle 慢的问题吗?还是您有千斤顶转换缓慢的问题?
  • 我在其他项目中的 gradle 构建在 2 分钟内完成。但在千斤顶中的改造在 6_7_10 分钟内完成

标签: build java-8 android-gradle-plugin android-jack-and-jill


【解决方案1】:

了解 Gradle Build 与您的 CPU 速度或 RAM 无关。构建在您的 PC 中变慢的原因是由于您的 Internet 连接。构建大约需要大约 100 MB。的数据来完成它的过程。即使您的 Internet 连接速度很快,而连接的 PING 速度很慢,也需要更多时间。感谢您的宝贵时间。

【讨论】:

  • 我不明白 transformJackWithJackForDebug 与我的互联网连接有什么关系!
【解决方案2】:

尝试将 AndroidStudio 更新到 3.0,升级 gradle gradle:2.2.3 => gradle:3.0.0 和 buildtools buildToolsVersion '25.0 .2' => buildToolsVersion '26.0.2'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-23
    • 2014-03-31
    • 1970-01-01
    • 2020-11-12
    • 2023-03-05
    • 2015-08-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多