【发布时间】:2014-03-31 01:06:06
【问题描述】:
我们已将 Android 应用项目更改为使用 gradle,但注意到它的构建速度明显变慢。
在使用 ANT 之前:
6 sek / 50 秒(清洁)
使用 gradle 之后:
30 sek / 80 秒(清洁)
我已经描述了解决方案:
gradle assembleDebug --profile
生成的报告中的主要任务是他们的任务:(在没有清理的构建中)
:packageDebug 10.690s
:processDebugResources 8.795s
:compileDebugJava 7.644s
我不知道如何获取有关此任务的更多详细信息。
这正常吗?如何改进?
我知道新的构建系统仍处于测试阶段,但似乎其他人的构建速度要快得多。
我环顾四周没有找到解决方案我尝试了几件事,包括确保使用包含以下内容的 gradle.properties 文件启用 gradle deamon:
org.gradle.daemon=true
org.gradle.jvmargs=-Xms128m -Xmx256m
org.gradle.parallel=true
build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
classpath 'com.google.guava:guava:14.0.1'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
classpath 'me.tatarka:gradle-retrolambda:1.1.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
}
}
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
apply plugin: 'android'
apply plugin: 'crashlytics'
apply plugin: 'retrolambda'
apply plugin: 'android-apt'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.google.guava:guava:14.0.1'
compile 'com.crashlytics.android:crashlytics:1.+'
apt "org.androidannotations:androidannotations:3.0.1"
compile "org.androidannotations:androidannotations-api:3.0.1"
}
apt {
arguments {
resourcePackageName "com.example"
androidManifestFile variant.processResources.manifestFile
}
}
android {
packagingOptions { //Fix: http://stackoverflow.com/a/20675331/860488
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 10
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 10
buildConfigField "boolean", "useProductionServices", "true"
}
buildTypes {
testflight.initWith(buildTypes.debug)
debug {
packageNameSuffix ".debug"
buildConfigField "boolean", "useProductionServices", "false"
}
testflight {
packageNameSuffix ".testflight"
buildConfigField "boolean", "useProductionServices", "true"
}
release {
buildConfigField "boolean", "useProductionServices", "true"
}
}
}
retrolambda {
compile "net.orfjackal.retrolambda:retrolambda:1.1.2"
jdk System.getenv("JAVA8_HOME")
}
【问题讨论】:
-
您找到解决方法了吗? Gradle 太慢了。我没有发现这有帮助 - stackoverflow.com/questions/16775197/…
标签: android android-studio intellij-idea gradle