2017-03-05 100 views
4

我检查了所有有关缓慢gradle构建的问题。 (例如here,here和......)但是在我的项目中构建gradle太慢了。有时这些建筑大约需要5-8小步舞,我搜索在很多网站,现在即时通讯累慢速编译在Android的gradle

的build.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

任何一个能帮助我吗?

+1

生成构建扫描(https://plugins.gradle.org/plugin/com.gradle.build-scan),或者至少使用--profile选项运行,以查找*什么*很慢,以及应该改进哪些内容。 –

+1

:app:transformJackWithJackForDebug >>这很慢。我认为它的杰克选项 – b4hr4m

+0

我不太了解android,也不知道这个dask是什么,或者它做了什么。但如果这很慢,你真的有一个gradle慢的问题?或者你有一个千斤顶变换慢度问题? –

回答

0

尝试更新AndroidStudio至3.0,升级gradle这个的gradle:2.2.3 =>的gradle:3.0.0和编译工具 buildToolsVersion '25 .0.2' => buildToolsVersion '26 .0.2'

0

了解Gradle Build与CPU速度或RAM无关。您的PC中Build的原因是因为您的Internet连接。构建可能需要将近100MB左右。的数据来完成它的过程。即使您的Internet连接速度很快,并且连接的PING速度较慢,也需要更多时间。谢谢你的时间。

+6

我不明白什么transformJackWithJackForDebug与我的互联网连接! –