当将com.android.tools.build:gradle:2.2.3
更新为com.android.tools.build:gradle:3.0.0
时,我发现构建时间超过2.3.3。
根build.gradle
是
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
app/build.gradle
在这里,我所有的依赖都使用compile
apply plugin: 'com.android.application'
android {
sourceSets {
main {
...
}
}
dexOptions {
preDexLibraries = false
incremental true
javaMaxHeapSize "8g"
keepRuntimeAnnotatedClasses false
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'org/apache/commons/codec/language/bm/*.txt'
}
compileSdkVersion 24
buildToolsVersion "27.0.1"
}
defaultConfig {
applicationId "com.gg.kk"
minSdkVersion 15
targetSdkVersion 23
versionCode 512654
versionName "version"
multiDexEnabled true
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.1'
.... many dependencies ....
}
谁能告诉我为什么我的构建变得缓慢?
许多不同的东西都会影响gradle构建时间。
要减少此时间,您可能需要至少尝试以下解决方案之一:
gradle.properties
在org.gradle.parallel=true
中启用并行性'com.android.support:appcompat-v7:27.+'
等动态依赖项File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
检查'Offline work'
'Global Gradle settings'
短期解决方案。